Remember Me token timeout not working in laravel 5.4

Viewed 1489

In Laravel 5.4 I have customized login method of authentication module and done user login using below method:

if($request->remember== 1)
    Auth::loginUsingId($user_id,TRUE);
else
    Auth::loginUsingId($user_id);

Here i have set second argument TRUE when remember me checkbox checked.

And customize cookie time in sendLoginResponse method:

$customRememberMeTimeInMinutes = 5;  
$rememberTokenCookieKey = Auth::getRecallerName(); 
Cookie::queue($rememberTokenCookieKey, Cookie::get($rememberTokenCookieKey), $customRememberMeTimeInMinutes);

After done above step my remember me token not working as expected(after 5 min i refreshed browser and still user logged in).

Default Session configuration is like this

'lifetime' => 120,

'expire_on_close' => false,

Please suggest what i am doing wrong?

1 Answers

Remember me only avoids filling in the login page. It does not preserve the session. Default lifetime is 120 (minutes) if the user does not submit an additional request in this time then the session is lost, and will be garbage collected at some point. If you want to change session timeout time then you have to go to config/session.php

/*
|--------------------------------------------------------------------------
| 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,  // number of minutes you want to increase / decrease

'expire_on_close' => false,
Related