【问题标题】:Laravel 5.5 The page has expired due to inactivity error while sending formLaravel 5.5 由于发送表单时出现不活动错误,页面已过期
【发布时间】:2017-10-03 19:25:25
【问题描述】:

我正在使用 laravel 5.5,它告诉我“由于不活动,该页面已过期。请刷新并重试。”这很尴尬,因为我从来没有遇到过这个错误。相同的代码,但不同的 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,
];

【问题讨论】:

  • 您使用的会话驱动程序是什么?签到config/session.php
  • 在我看来,您尝试提交的表单中缺少 {{ csrf_field() }}。你能确认它在那里吗?
  • 我正在使用 laravelcollective 的表单.. 表单包含 csrf 令牌
  • 如果季节已过期或表单 csrf 字段已更改,则会出现此消息
  • 你能提供你的代码吗? (session.php) 和你的表单?

标签: laravel laravel-5.5


【解决方案1】:

由于这些命令已经解决了您在 cmets 中的问题,我应该将其写为答案。尝试这些命令并重新开始您的表单

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

【讨论】:

    【解决方案2】:

    我假设您正在使用 laravel 集合作为表单构建器。

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

    请检查上面的链接,并确保您包含基于方法或显式 Form::token() 的 CSRF;

    【讨论】:

    【解决方案3】:

    另一点是 Laravelcollective 可能不适用于 laravel 5.5。您可以在 GitHub 上查看此问题,并在 Laravel 5.5 https://github.com/LaravelCollective/html/issues/364987654321@中找到集体的解决方法

    【讨论】:

      【解决方案4】:

      试试下面的语句:

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

      它对我有用。享受

      【讨论】:

        猜你喜欢
        • 2018-07-22
        • 2018-08-30
        • 2018-03-28
        • 1970-01-01
        • 2018-09-16
        • 2018-12-31
        • 2018-08-31
        • 2018-02-19
        • 1970-01-01
        相关资源
        最近更新 更多