简体   繁体   English

laravel有什么用处记住我的令牌?

[英]What is the use of laravel remember me token?

I have a couple of problems with understanding Laravel remember me functionality. 我有一些理解Laravel的问题,记住我的功能。

  1. What is the connection between remember me functionality and remember_me column in users table ? users表中记住我的功能和remember_me列之间的联系是什么?
  2. Is there a timeout for this functionality? 此功能是否超时?

Thank you. 谢谢。

Laravel authentication offers remember me functionality out of the box. Laravel身份验证提供了开箱即用的功能。

In order to use it you need to do 2 things: 为了使用它,你需要做两件事:

add remember_token column in your users table - this is where the token will be stored pass true as a second parameter of Auth::attempt() to enable remember me behaviour If you do this, Laravel will generate a token that will be saved in users table and in a cookie. 在users表中添加remember_token列 - 这是存储令牌的位置,将其作为Auth :: attempt()的第二个参数传递,以便记住我的行为如果这样做,Laravel将生成一个将保存在用户中的令牌桌子和饼干。 On subsequent requests, even if session cookie is not available, user will be authenticated automatically as long as remember-me cookie is there. 在后续请求中,即使会话cookie不可用,只要记住我的cookie,用户就会自动进行身份验证。

You can find more details and example in the docs: Click Here 您可以在文档中找到更多详细信息和示例: 单击此处

There is a good documentation on this as well here 在灯架上有一个好的文档,以及在这里

  1. But yes, there is a connection and that's set when you select the remember me option when you log in. 但是,是的,有一个连接,当你登录时选择记住我选项时设置。
  2. It lasts indefinitely, so there is no timeout. 它会无限期地持续,所以没有超时。

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

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