【问题标题】:Laravel Inactivity time settingLaravel 不活动时间设置
【发布时间】:2014-07-30 19:02:21
【问题描述】:

当用户登录并保持非活动状态时,系统自动注销用户后多少秒?如何更改此设置?

【问题讨论】:

    标签: laravel timeout logout


    【解决方案1】:

    假设您使用会话驱动程序来处理您的身份验证,您可以在 /app/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,
    
    'expire_on_close' => false,
    

    【讨论】:

    • 那么在 120 秒之后,所有的 Auth::user 都会被自动注销?对吗?
    • 现在是 分钟。因此,120 分钟后,用户将被注销。
    • 哦,不错。感谢澄清。所以我假设在 119.999 分钟,程序会在某个时候自动调用 Auth::logout(); 函数。那正确吗 ?你知道在 Laravel 哪里吗?我问这个的原因是因为我想在注销功能之前在我的数据库中设置一些值。我希望能收到您的回音。 :)
    • 程序不会自动注销用户。每次用户访问网站上的页面时,它都会检查他们上次访问之间的时间是否 > x 分钟。如果是,则应用程序将它们注销,但用户需要访问该站点才能触发此操作。
    • @NightMICU 如果您想在每次用户注销时触发一些代码,您可以使用event subscriber 来处理auth.logout 事件。
    猜你喜欢
    • 1970-01-01
    • 2019-06-12
    • 1970-01-01
    • 2011-03-14
    • 1970-01-01
    • 2017-12-23
    • 2017-04-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多