最新消息:XAMPP默认安装之后是很不安全的,我们只需要点击左方菜单的 "安全"选项,按照向导操作即可完成安全设置。

学习 Laravel 那些坑(三) csrf_token()

XAMPP下载 admin 1458浏览 0评论

laravel 5.5 填写注册信息时遇到错误信息
The page has expired due to inactivity.
Please refresh and try again

http 状态 419 Authentication Timeout (not in RFC 2616)

这时 url 已跳转到 login,显然登录时有问题;查了下是 csrf_token 的问题;
php – laravel 5.5 The page has expired due to inactivity. Please refresh and try again – Stack Overflow

题主命中的 answer是:

This problem comes from the CSRF token verification which fails. So either you’re not posting one, or you’re posting an incorrect one.

The reason it works for GET is that for a GET route in laravel, there is no CSRF token posted.

You can either post a CSRF token in your form by calling:

{{ csrf_field() }}

Or exclude your route in app/Http/Middleware/VerifyCsrfToken.php

protected $except = [
‘your/route’
];

试过了,然并卵;不是这种情况;

后来想到 csrf 会不会是.env 里配置的问题,

APP_URL=localhost

修改为访问的 url,依然并卵;

后又修改 storage 权限,问题解决!

转载请注明:XAMPP中文组官网 » 学习 Laravel 那些坑(三) csrf_token()

您必须 登录 才能发表评论!