When user logged-in and remains inactive, How many seconds after that system logouts the user automatically? How to change this setting?
Laravel Inactivity time setting
Assuming you are using the session driver to handle your authentication, you can change the time period for an idle session to expire in the /app/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' => 120,
'expire_on_close' => false,
So after 120 s , to all the Auth::user will be auto logged out ? Is that correct ? –
Osteoma
It's minutes. So after 120 minutes the user will be logged out. –
Eunuchoidism
Ohh nice. Thanks for clarify. So I assume at the 119.999 minutes the program will automatically called the Auth::logout(); function at some point. Is that right ? Do you know where that in Laravel ? The reason why I am asking this, is because I want to set some value into my database before the log-out function. I hope to hear back from you. :) –
Osteoma
@Osteoma were you ever able to figure this out? I also want to run a command before auto logout –
Flaminius
The program will not automatically log the user out. Every time the user access a page on the site it will do a check to see if the time between their last visit is > x minutes . If it is, then the application logs them out, but the user needs to visit the site to trigger this. –
Eunuchoidism
@Flaminius If you want to trigger some code every time a user is logged out, you could use an event subscriber for the
auth.logout
event. –
Eunuchoidism @Eunuchoidism this also make the csrf token expire in the same time, is there a way to only expire the user's session? –
Baldridge
The location of this file has changed to
/config/session.php
–
Sokoto © 2022 - 2024 — McMap. All rights reserved.