【问题标题】:Laravel 5.6 The page has expired due to inactivity token is presentLaravel 5.6 由于存在不活动令牌,页面已过期
【发布时间】:2018-06-01 07:14:49
【问题描述】:

这里已经提出了同样的问题,我已经尝试了所有阅读。

我的旧问题参考 Laravel 5.5 The page has expired due to inactivity token is present

我尝试过: "The page has expired due to inactivity" - Laravel 5.5 https://www.5balloons.info/fixed-page-expired-due-inactivity-laravel-5/

我已经尝试过缓存和会话的文件和数据库,我所有的表单都有 TOKEN。

存储权限

 drwxrwxrwx  5 ABC ABC   4096 May 30 23:16 storage

我的 .env 文件

APP_NAME="Name"
APP_ENV=staging
APP_KEY=SOMEKEY
APP_DEBUG=false
APP_LOG_LEVEL=false
APP_URL=http://url

DB_CONNECTION=mysql
DB_HOST=mysql.host.com
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=db_user
DB_PASSWORD=db_user_password

BROADCAST_DRIVER=log
CACHE_DRIVER=database
SESSION_DRIVER=database
QUEUE_DRIVER=sync

表格

<form class="form-horizontal" method="POST" action="{{ route('password.request') }}">
        {{ csrf_field() }}

        <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">

            <div class="col-md-12">
                <label for="email" class="control-label">E-Mail Address</label>
                <input id="email" type="email" class="form-control" name="email" value="{{ $email or old('email') }}" required autofocus>

                @if ($errors->has('email'))
                    <span class="help-block">
                                    <strong>{{ $errors->first('email') }}</strong>
                                </span>
                @endif
            </div>
        </div>

我在这里错过了什么,不知道。

【问题讨论】:

    标签: laravel-5


    【解决方案1】:

    尝试做这些:

    php artisan cache:clear
    php artisan config:clear
    php artisan route:clear
    php artisan view:clear
    php artisan config:cache
    

    并且在控制器构造函数中尝试刷新会话,因为这个 csrf_token 存储在每个用户的会话中。

    public function __construct()
    {
        Session::flush();
    }
    
    Session::regenerateToken(); // Which generates a new token on request.
    

    你也可以试试这个:

    <input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
    

    【讨论】:

    • 我忘了运行 php artisan config:cache,它解决了这个问题。谢谢
    猜你喜欢
    • 2019-07-11
    • 2018-10-01
    • 1970-01-01
    • 2018-12-31
    • 2018-08-31
    • 2018-12-10
    • 2018-07-22
    • 1970-01-01
    • 2018-08-30
    相关资源
    最近更新 更多