I wanted to put in the login
page a checkbox "stay logged in".
That should never end the session of the user unless the user logs out.
I know that in app/config/session.php I have these variables:
'lifetime' => 60,
'expire_on_close' => false,
But I wanted to maintain alive the session forever, and not be removed if the user close his navigator.
Any ideas on how should I proceed? Thanks
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.
If you want to increase your session life time then we need to change in . env file and it is very easy to change it from configuration file in laravel. laravel provides you session. php file there is we can see 'lifetime' key option for setting time in minutes.
By default it is set to 1440. Just comment or delete it. From this time on you session may work properly using your session. php config values.
Your users table must include the string remember_token column, which will be used to store the "remember me" token. if (Auth::attempt(['email' => $email, 'password' => $password], $remember)) { // The user is being remembered... }
Laravel has a built-in feature to remember users, I'd strongly recommend using it.
If you would like to provide "remember me" functionality in your application, you may pass a boolean value as the second argument to the attempt method, which will keep the user authenticated indefinitely, or until they manually logout. Of course, your users table must include the string remember_token column, which will be used to store the "remember me" token.
if (Auth::attempt(['email' => $email, 'password' => $password], $remember)) {
// The user is being remembered...
}
if you want to solve the problem manually, there is workaround for this: you have to set the expires date of your cookie to a date in the wide future, somewhat like 2050. this is technically not forever, but should usually be long enough.
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