【问题标题】:Laravel 5.1 prevent token mismatch after form idleLaravel 5.1 防止表单空闲后令牌不匹配
【发布时间】:2015-09-10 09:20:20
【问题描述】:

我有一个 Laravel 应用程序,它有一个用户会员系统,用户可以注册和登录。如果我让登录表单闲置一段时间然后尝试登录,则会收到以下错误:

TokenMismatchException in VerifyCsrfToken.php

避免这个问题的最佳方法是什么?

【问题讨论】:

    标签: php laravel laravel-5


    【解决方案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' => 15,
    
    'expire_on_close' => false,
    

    要记住的一点是,至少在 Laravel 4.2 中,当 expire_on_close 设置为 true 时,lifetimeignored

    【讨论】:

      猜你喜欢
      • 2015-11-07
      • 2016-04-29
      • 2013-08-07
      • 1970-01-01
      • 1970-01-01
      • 2016-01-12
      • 2015-10-24
      • 2017-03-26
      • 2016-10-24
      相关资源
      最近更新 更多