php - Laravel with two different lifetime sessions -


i'm trying implement 'remember me' login using laravel framework. when user checks 'remember me' box, laravel keeps session data month. if user unchecked it, want keep session until user closes browser.

i know how control session when 'remember me' checked. configured sessions in config/session.php below:

'lifetime' => 43200, 'expire_on_close' => false, 

and i'm using sessions global session helper

session(['accesstoken' => some_access_token]); session::flush(); 

and on.

but don't know how work when user logging in 'remember me' unchecked. tried find way control configuration

'expire_on_close' => true, 

on fly, based on user input, failed. please tell me how keep 2 different session lifetime configuration within 1 laravel framework. or if i'm trying 'remember me' feature in wrong way, please guide me.

basically, stated above, i'd keep session in month 'remember me', , keep session until browser closing without 'remember me'.

thanks.

in order remember me functionality shouldn't work session configuration. instead, should use functionality built laravel.

when authenticate user auth::attempt(), can pass boolean value second argument. set true, if user checked remember me checkbox. set false otherwise.

this way, when checkbox checked, user remembered till manually log out of application. otherwise, they'll remembered till close browser or session expires.

you can find more informaton here: https://laravel.com/docs/5.3/authentication#remembering-users


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -