Can we set expiration time for each session in Laravel?
If possible, how can we set the expiration time through the controller for each session we create? Thanks.
P粉4751269412023-07-24 10:54:00
Please change SESSION_LIFETIME= (duration in minutes) to the value in the .env file.
P粉8541192632023-07-24 09:47:32
You can change the lifetime of the session globally by changing the lifetime value in the config/session.php file:
/* |-------------------------------------------------------------------------- | 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' => 4320, 'expire_on_close' => false,
Now, if you want to control the session lifetime for each user, you need to set this value before the user logs in.
You need to make the above changes in LoginController.