0

我想在我的应用程序中实现“锁定窗口”功能。是否可以锁定会话并重新激活它?

案例: x 分钟后,应用程序将被锁定。用户现在必须输入他的密码,然后将被重定向到以前的路线并再次登录。

4

1 回答 1

1

在 /config/session.php 中,您可以设置会话到期前的空闲时间:

   /*
    |--------------------------------------------------------------------------
    | Session Lifetime
    |--------------------------------------------------------------------------
    |
    | Here you may specify the number of minutes that you wish the session
    | to be allowed to remain idle before it expires. If you want them
    | to immediately expire on the browser closing, set that option.
    |
    */

    'lifetime' => 120, // edit this

如果您想包括非空闲时间,您可以创建一些可以自动注销用户的中间件。您可以在会话中存储用户登录的时间,并在中间件中存储您的$timeout变量。您可以像这样强制注销身份验证用户:

auth()->logout()

如果登录的时间$timeout已经过去。

于 2019-03-04T10:44:56.727 回答