簡體   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