简体   繁体   English

Laravel 5.1记得我功能不起作用

[英]Laravel 5.1 remember me functionality is not working

I am working on laravel 5.1. 我正在研究laravel 5.1。 I have created login functionality with the remember me feature. 我已经使用remember me功能创建了登录功能。
I check user authentication with the help of auth function: 我在auth函数的帮助下检查用户身份验证:

$this->auth->attempt(['email' => $email, 'password' => $request->input('password')], true)

From login when I check checked box and submit login detail it will create a cookies token like this: 从登录时选中复选框并提交登录详细信息,它将创建一个这样的cookie令牌:

remember_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

But when I am logged out by this function $this->auth->logout() the login does not show the filled previous login detail and this cookies token is also destroyed. 但是当我通过此函数$this->auth->logout() ,登录不显示填充的先前登录详细信息,并且此cookie令牌也被销毁。

You have misunderstood how Remember Me feature is intended to work. 您误解了“ 记住我”功能是如何工作的。 It's supposed to remember users even if server session has expired or removed, eg after user browser is closed. 即使服务器会话已过期或已删除,也应该记住用户,例如在用户浏览器关闭后。

When user clicks Logout , they're explicitely saying that they don't want to be logged in anymore, that's why remember me cookie is deleted. 当用户单击Logout时 ,他们明确表示他们不想再登录,这就是为什么要记住我的 cookie被删除。

See some more details in the docs: http://laravel.com/docs/5.0/authentication 请参阅文档中的更多详细信息: http//laravel.com/docs/5.0/authentication

Especially this part: 特别是这部分:

If you would like to provide "remember me" functionality in your application, you may pass a boolean value as the second argument to the attempt method, which will keep the user authenticated indefinitely, or until they manually logout. 如果您想在应用程序中提供“记住我”功能,您可以将一个布尔值作为第二个参数传递给attempt方法,这将使用户无限期地进行身份验证,或者直到他们手动注销。

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

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