According to Laravel 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' => true, 'expired-session-redirect' => url(env('APP_URL'))
I have set the lifetime of my session to 120
minutes, but I have a feeling that my user is log-out way before 120 minutes.
Is that a typo ? Do they mean 120 seconds which is 2 mins ?
Can anyone please shed some lights on this ?
If you want to increase your session life time then you can easily do it from configuration file in laravel. laravel provide session. php there is a 'lifetime' key option for setting time in minutes. in session configuration file there is a also several option for set driver, timeout, expire_on_close and encrypt etc.
You need to understand what happened: You've set the lifetime of the sessions to 120 minutes, which means after 120 minutes the session is flushed. The remember_me feature is using cookies. If there is no user session Laravel checks the cookies and recreates the session if the session cookie is still valid.
By default in laravel application session timeout value is 120 minutes.
The default session location is the /tmp directory, and the garbage collection routine will run every 24 minutes for these other sites (and wipe out your sessions in the process, regardless of how long they should be kept).
Check your php.ini for:
session.gc_maxlifetime - Default 1440 secs - 24 mins
session.gc_maxlifetime specifies the number of seconds after which data will be seen as 'garbage' and potentially cleaned up. Garbage collection may occur during session start (depending on session.gc_probability and session.gc_divisor).
session.cookie_lifetime - Default 0
session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0. See also session_get_cookie_params() and session_set_cookie_params().
In case it is less time than the Laravel configuration, the cookie will be removed because the local php.ini have preference over Laravel configuration.
You can just increase it or comment/delete.
In case is not solved something on your App is destroying the session.
UPDATE
After release v5.5.22 session lifetime is loaded from .env
and is not hardcoded anymore at config/session.php
, changes there.
Now you can modify the session lifetime using:
SESSION_LIFETIME=
In your .env
file.
Change .env
file in your app root
SESSION_LIFETIME=120
And value is in minutes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With