Laravel 5.6 Session不是持久的

It's very strange for me as I have multiple projects on which I am currently working & all are working fine but this one project has issues with sessions. Session data doesn't persist.

I am using Laravel 5.6 & session drive file

What I tried:

  • Moved \Illuminate\Session\Middleware\StartSession::class, from $middlewareGroups to $middleware
  • In web.php tried adding web middleware & remvoing it as well
  • Clear config & cache
  • Removed files from storage\framework\sessions. BTW files are creating in this directory when a put something in session
  • Used both ways of adding data session(['key'=>'value']) & session()->put(['key','value']
  • Used Session Facade as well

No luck With all these. One more thing, After session()->put() when I tried to print data on same page from session, it is printed.

This question may seems to be duplicate to you first, but I have did complete search on it & followed instructions in laravel 5.6 session not persisting when view returned but no luck.

You are setting session wrongly use session()->put('key', 'value'); And make sure when you are using file driver, the directory where sessions kept is writable.

Also make sure that in you browser cookies are enabled.

For more information about sessions use this link