“由于不活动,页面已过期"- Laravel 5.5 [英] "The page has expired due to inactivity" - Laravel 5.5

查看:41
本文介绍了“由于不活动,页面已过期"- Laravel 5.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的注册页面正确显示了表单,并且表单中存在 CsrfToken ({{ csrf_field() }}).

My register page is showing the form properly with CsrfToken ({{ csrf_field() }}) present in the form).

表单 HTML

<form class="form-horizontal registration-form" novalidate method="POST" action="{{ route('register') }}">
        {{ csrf_field() }}
        ....
</form>

我正在为用户使用内置身份验证.除了路由和重定向之外没有改变任何东西.

I am using inbuilt authentication for the users. Have not changed anything except the routes and redirects.

当我提交表单时(刚刚重新加载后),它显示 由于不活动,页面已过期.请刷新并重试.错误.

When I submit the form (just after reloading also), it gives that The page has expired due to inactivity. Please refresh and try again. error.

我是我错过了一件很小的事情.但不确定它是什么.有什么帮助吗?

My be I am missing a very small thing. But not sure what it is. Any help?

更新

发现问题.会话驱动程序设置为数组.将其更改为文件,现在错误消失了.但是如果我使用数组有什么问题?

Found the issue. The session driver was set to array. Changed it to file and the error is gone now. But what is wrong if I use array?

推荐答案

如果您是直接通过搜索获得此答案,请确保您已将 csrf 标记添加到您的表单中{{ csrf_field() }} 就像 OP.

If you're coming to this answer directly from a search, make sure you have already added the csrf token to your form with {{ csrf_field() }} like the OP.

如果您将会话驱动程序设置为文件:

可能与 storage_path 不可写有关.如果您使用基于文件的会话,它就是存储有关令牌的会话数据的地方.可以用 is_writable(config('session.files'))

May have something to do with the storage_path not being writable. This is where it stores session data regarding tokens if you're using file based sessions. The can be verified with is_writable(config('session.files'))

对于 OP,会话驱动程序设置为数组. 数组仅用于测试.由于数据未持久化,因此无法在下一次请求时比较令牌.

For the OP, the session driver was set to array. Array is for testing only. Since data is not persisted, it will not be able to compare the token on the next request.

阵列驱动在测试时使用,防止数据存储在会话中被持久化.

The array driver is used during testing and prevents the data stored in the session from being persisted.

https://laravel.com/docs/5.5/session#configuration

检查 config/session.php

最后,我刚刚遇到的一个问题,我们有一个项目,它在 config/session.php 中有会话域和安全设置,但开发站点没有使用 HTTPS (SSL/TLS).这导致了这个通用错误,因为 session.secure 默认设置为 true.

Lastly, an issue I just had, we had a project which has the session domain and secure settings in config/session.php but the development site was not using HTTPS (SSL/TLS). This caused this generic error since sessions.secure was set to true by default.

这篇关于“由于不活动,页面已过期"- Laravel 5.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆