Laravel 5.1 记住我的功能不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31534392/
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
Laravel 5.1 remember me functionality is not working
提问by Alok Bichhwe
I am working on laravel 5.1. I have created login functionality with the remember me feature.
I check user authentication with the help of auth function:
我正在研究 Laravel 5.1。我已经使用记住我功能创建了登录功能。
我在 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 令牌也被销毁。
回答by jedrzej.kurylo
You have misunderstood how Remember Mefeature is intended to work. It's supposed to remember users even if server session has expired or removed, e.g. 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 mecookie 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.
如果您想在您的应用程序中提供“记住我”功能,您可以将一个布尔值作为第二个参数传递给尝试方法,这将使用户无限期地进行身份验证,或者直到他们手动注销。