Fix laravel 5 session expiring after updating or switching to another page?

I am using laravel default Auth. When I enter my site everything works fine. When I try to refresh or go to another page (still using Auth middleware), my session has expired, I immediately logged off and I have to log in again. How can I fix this, so I stay on when I refresh the page or view another?

+4
source share
3 answers

It is worth changing (app / session.php):

'cookie' => 'laravel_session'

Something related to your application / website as it is reset every time the cache compiles

+1
source

sesssion :

config/session.php

'driver' => env('SESSION_DRIVER', 'file')

, "//":

'files' => storage_path('framework/sessions')
+1

You can also 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,

Please note that with expire_on_clone, if you set it to true, the session expires when the browser is closed.

0
source

Source: https://habr.com/ru/post/1607425/


All Articles