0

My laravel website session is still stored in /storage/framework/sessions. after logout.

I try to use Session::flush but its not working

how I can delete these sessions.

1 Answers1

0

Old session files will be deleted only after the Session garbage collector is called, the function is gc().

This function has a probability to be called on every request, you can control the chances it will run with the session.lottery config value.

But do not worry, even if the session files are still present they are invalidated after logout, only deletion occur with the gc() function above.

The same is true for database session records.

Nor Session::flush() nor Session::regenerate(true) will delete old session file.

dparoli
  • 8,891
  • 1
  • 30
  • 38
  • yes. but problem is when i logout from system it redirect me to home page. that's fine. but i will be able to access that previous page until i refresh browser –  Jul 30 '19 at 13:25
  • Do you use the Auth system shipped with Laravel or a custom one? – dparoli Jul 30 '19 at 13:46
  • custome one. Actully when i make changes in views or controller it doesn't work until i delete views and sessions in storage/framework directory –  Jul 30 '19 at 14:03
  • The one that ships with Laravel does not have this problems, it is higly recommended to use it instead of a custom one. As written your question does not provide a minimal, workable example: I was thinking you were using the Laravel Auth system. – dparoli Jul 30 '19 at 14:09
  • but what about views and sessions which are storing in framework folder. if the get deleted system work properply –  Jul 30 '19 at 14:12
  • Sorry mate, I don't want to argue with you, but the fact is that if your system works only if old views and sessions files are deleted manually it does not work well. My advice is to use the regular Laravel Auth system and learn deeply how it works before reinvent a new one. – dparoli Jul 30 '19 at 14:21
  • changes in Controller are not reflecting i dont think it is issue related to regular Auth –  Jul 30 '19 at 14:38
  • Please accept and upvote an answer if you found it useful – dparoli Jul 30 '19 at 16:27