Reputation: 43
I'm using laravel default Auth. When I login into my website all works great. When I try to refresh or go to another page (still using Auth middleware) my session is expired, I'm directly logged-out and I must login again. How can I fix this so I remain logged in when refreshing the page or browsing to another?
Upvotes: 4
Views: 3043
Reputation: 450
You can also try to set a higher lifetime in config/session.php
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => 120,
'expire_on_close' => false,
Note with expire_on_close
if you set this to true, session will expire when a browser is closed
Upvotes: 0
Reputation: 305
It's worth changing (app/session.php):
'cookie' => 'laravel_session'
To something relevant to your app/website as it is reset every time the cache is compiled
Upvotes: 3
Reputation: 622
Check sesssion config file in:
config/session.php
If you have
'driver' => env('SESSION_DRIVER', 'file')
check the permissions on sessions folder that default is 'storage/framework/sessions':
'files' => storage_path('framework/sessions')
Upvotes: 1