繁体   English   中英

记住我令牌超时在Laravel 5.4中不起作用

[英]Remember Me token timeout not working in laravel 5.4

在Laravel 5.4中,我自定义了身份验证模块的登录方法,并使用以下方法完成了用户登录:

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

在这里,我选中了“记住我”复选框后,将第二个参数设置为TRUE。

并在sendLoginResponse方法中自定义cookie时间:

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

完成上述步骤后,我记得我的令牌无法按预期工作(5分钟后,我刷新了浏览器,仍然用户登录了)。

默认会话配置是这样的

'lifetime' => 120,

'expire_on_close' => false,

请指出我做错了什么?

记住我只是避免填写登录页面。 它不保留会话。 如果用户此时未提交其他请求,则默认生存期为120(分钟),则会话将丢失,并在某些时候被垃圾回收。 如果要更改会话超时时间,则必须转到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,

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM