I'm trying to implement 'remember me' login using laravel framework. When user checks 'remember me' box, laravel keeps session data for a month. If user unchecked it, I want to keep session until user closes the browser.
I know how to control session when 'remember me' is checked. I configured sessions in config/session.php like below:
'lifetime' => 43200,
'expire_on_close' => false,
session(['accessToken' => SOME_ACCESS_TOKEN]);
'expire_on_close' => true,
In order to get remember me functionality you shouldn't work with session configuration. Instead, you should use the functionality already built into Laravel.
When you authenticate user with Auth::attempt(), you can pass a boolean value as the second argument. Set it to true, if user checked remember me checkbox. Set it to false otherwise.
This way, when checkbox is checked, user will be remembered till they manually log out of application. Otherwise, they'll be remembered till they close the browser or session expires.
You can find some more informaton here: https://laravel.com/docs/5.3/authentication#remembering-users