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:
\Illuminate\Session\Middleware\StartSession::class,
from $middlewareGroups
to $middleware
web.php
tried adding web
middleware & remvoing it as wellstorage\framework\sessions
. BTW files are creating in this directory when a put something in sessionsession(['key'=>'value'])
& session()->put(['key','value']
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