Laravel 5.5 由于发送表单时出现不活动错误,页面已过期

Laravel 5.5 The page has expired due to inactivity error while sending form

我正在使用 laravel 5.5,它告诉我 "The page has expired due to inactivity. Please refresh and try again." 这很尴尬,因为我从来没有遇到过这个错误。代码相同但 laravel 版本不同..

我的表格;

{!! Form::open(['url'=>'admin/save-social']) !!}
{{ Form::label('pinterest', 'Pinterest;', ['class' => 'control-label']) }}
{{ Form::text('pinterest', null, ['class' => 'form-control'])}}
{{ Form::label('linkedn', 'Linkedn;', ['class' => 'control-label'])}}
{{ Form::text('linkedn', null, ['class' => 'form-control'])}}
{{ Form::label('facebook', 'Facebook;', ['class' => 'control-label']) }}
{{ Form::text('facebook', null, ['class' => 'form-control']) }}
{{ Form::label('twitter', 'Twitter;', ['class' => 'control-label']) }}
{{ Form::text('twitter', null, ['class' => 'form-control']) }}
{{ Form::label('instagram', 'İnstagram;', ['class' => 'control-label']) }}
{{ Form::text('instagram', null, ['class' => 'form-control']) }}
{{ Form::submit('Save', ['class'=>'btn btn-success btn-lg btn-block']) }}
{!! Form::close()!!}

config/session.php

<?php

return [
    'driver' => env('SESSION_DRIVER', 'file'),
    'lifetime' => 120,
    'expire_on_close' => false,
    'encrypt' => false,
    'files' => storage_path('framework/sessions'),
    'connection' => null,
    'table' => 'sessions',
    'store' => null,
    'lottery' => [2, 100],
    'cookie' => env(
        'SESSION_COOKIE',
        str_slug(env('APP_NAME', 'laravel'), '_').'_session'
    ),
    'path' => '/',
    'domain' => env('SESSION_DOMAIN', null),
    'secure' => env('SESSION_SECURE_COOKIE', false),
    'http_only' => true,
    'same_site' => null,
];

我假设您正在使用 laravel 表单生成器的集合。

您的问题可能与 CSRF 保护 (https://laravelcollective.com/docs/master/html#csrf-protection) 有关。

请检查以上内容 link 并确保包含基于方法或显式 Form::token();

的 CSRF

另一点是 Laravelcollective 可能不适用于 laravel 5.5。您可以从 GitHub 检查此问题并在 Laravel 5.5 https://github.com/LaravelCollective/html/issues/364

中找到 collective 的解决方法

既然这些命令已经解决了你在评论中的问题,我应该把它写成答案。尝试这些命令并重新开始你的表单

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

尝试以下语句:

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

它对我有用。享受