嗨,我希望你们一切都好..我是 Laravel 的新手。 我希望,如果用户在成功注册网站后登录,并在一段时间或几天后甚至每次访问时访问我的网站,他都会自动登录网站。 我搜索了很多东西,但对我不起作用。请建议我更好的方法来做到这一点 这是我的网站链接Salebaba
这是自定义网站,使用 Laravel 开发
最佳答案
记住用户
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. Your users table must include the string remember_token column, which will be used to store the "remember me" token.
if (Auth::attempt(['email' => $email, 'password' => $password], $remember = true)) {
// The user is being remembered...
}
您还可以将 Laravel cookie session 生命周期设置为 10080 分钟(7 天)作为示例
关于javascript - Laravel 再次访问网站时自动登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60445773/