laravel 记住我没有工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49232912/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:30:17  来源:igfitidea点击:

laravel remember me not working

phplaravellaravel-5.6

提问by Pranav Mandlik

I have created 2 different login forms for admin and users in admin login form i have used attempt function i want to use remember me functionality but when i log in to the system without clicking remember me checkbox i can see in database it stores some value is it normal that its storing values not checking remember me token ? this is my code for admin login

我为管理员和管理员登录表单中的用户创建了 2 个不同的登录表单我使用了尝试功能我想使用记住我的功能但是当我登录系统时没有点击记住我复选框我可以在数据库中看到它存储了一些值它的存储值不检查记住我令牌是正常的吗?这是我的管理员登录代码

 if (Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
    // if successful, then redirect to their intended location
    return redirect()->intended(route('admin.dashboard'));
  }

can someone please help me with remember me functionality in laravel

有人可以帮我记住 laravel 中的功能吗

回答by siddhant sankhe

Try passing boolean value as second parameter to method attempt , or

尝试将布尔值作为第二个参数传递给方法尝试,或

if (Auth::viaRemember()) {
   //
}

use viaRememberin new laravel versions

使用viaRemember新版本的laravel

also , check your config/session.php setting

另外,检查您的 config/session.php 设置

'lifetime' => 10080,
'expire_on_close' => true,

just set your expire_on_closeto trueand Auth with Auth::viaRemember()

只需将您的expire_on_closetotrue和 Auth设置为Auth::viaRemember()

hope this is helpful

希望这是有帮助的