Laravel 5.5 发送表单时由于不活动错误导致页面已过期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46551940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5.5 The page has expired due to inactivity error while sending form
提问by wahdan
I'am using laravel 5.5 and it gives me that "The page has expired due to inactivity. Please refresh and try again." This is awkward because I never encounter this error. Same codes but different laravel version..
我正在使用 laravel 5.5,它告诉我“由于不活动,页面已过期。请刷新并重试。” 这很尴尬,因为我从未遇到过这个错误。相同的代码但不同的 Laravel 版本..
My form;
我的表格;
{!! 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()!!}
And config/session.php
和 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,
];
回答by wahdan
Since these commands has solved your problem in the comments i should write it as an answer . Try these commands and start your form again
由于这些命令已在评论中解决了您的问题,因此我应该将其写为答案。尝试这些命令并再次启动您的表单
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
回答by Joaquin Lozano Cifuentes
I assume that you are using laravel collective for forms builder.
我假设您正在将 laravel 集体用于表单构建器。
Probably your issue is associate with CSRF Protection (https://laravelcollective.com/docs/master/html#csrf-protection).
可能您的问题与 CSRF 保护有关(https://laravelcollective.com/docs/master/html#csrf-protection)。
Please check the above link and ensure that you include CSRF based on method or explicit Form::token();
请检查上面的链接并确保您包含基于方法或显式 Form::token(); 的 CSRF;
回答by Joaquin Lozano Cifuentes
Another point is that Laravelcollective maybe not is available for laravel 5.5. You can check this issue from GitHub and find a workaround for collective in Laravel 5.5 https://github.com/LaravelCollective/html/issues/364
另一点是 Laravelcollective 可能不适用于 Laravel 5.5。您可以从 GitHub 检查此问题,并在 Laravel 5.5 https://github.com/LaravelCollective/html/issues/364 中找到集体的解决方法
回答by George Kwakye Addo
Try out the following statements:
试试下面的语句:
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
It worked for me. Enjoy
它对我有用。享受