使用Laravel提交POST请求出现The page has expired due to inactivity错误
使用Laravel提交POST请求出现The page has expired due to inactivity. Please refresh and try again.
问题:
提交POST请求,出现如下错误:
The page has expired due to inactivity. Please refresh and try again
这是由于在Laravel框架中有此要求:
任何指向 web 中 POST, PUT 或 DELETE 路由的 HTML 表单请求都应该包含一个 CSRF 令牌(CSRF token),否则,这个请求将会被拒绝。
解决办法1: 加上 CSRF token
<form method="POST" action="/profile">
{{ csrf_field() }}...
</form>
也可以最新写法
<form method="POST" action="/profile">@csrf...
</form>
如果是AJAX提交:
在页面头部加上csrf-token:
<meta name="csrf-token" content="{{ csrf_token() }}">
提交headers中增加 X-CSRF-TOKEN:
$.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}
});
解决办法2: 移除 CSRF token
也可以在指定页面移除CSRF保护:
/app/Http/Middleware/VerifyCsrfToken.php
<?phpnamespace App\Http\Middleware;use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;class VerifyCsrfToken extends Middleware
{/*** The URIs that should be excluded from CSRF verification.** @var array*/protected $except = ['stripe/*','http://example.com/foo/bar','http://example.com/foo/*',];
}
参考链接:
http://blog.csdn.net/qq_37107603/article/details/78891628
https://laravel.com/docs/5.6/csrf#csrf-introduction
[END]
使用Laravel提交POST请求出现The page has expired due to inactivity错误相关推荐
- 使用Larave5.6l提交POST请求出现The page has expired due to inactivity错误
使用Larave5.6l提交POST请求出现The page has expired due to inactivity错误 使用Larave5.6l提交POST请求出现The page has ex ...
- laravel 请求出现 post The page has expired due to inactivity.
使用Laravel提交POST请求出现:The page has expired due to inactivity. Please refresh and try again. 这是由于在Larav ...
- Laravel框架post的路由出现The page has expired due to inactivity. Please refresh and try again.
post提交数据时候显示如下: The page has expired due to inactivity. Please refresh and try again 这是由于在laravel框架中 ...
- laravel5.6 提示The page has expired due to inactivity. Please refresh and try again.的解决方法
post提交数据时候显示如下: The page has expired due to inactivity. Please refresh and try again 这是由于在laravel框架中 ...
- The page has expired due to inactivity Please refresh and try again
post提交数据时候显示如下: The page has expired due to inactivity. Please refresh and try again123 这是由于在laravel ...
- The page has expired due to inactivity. Please refresh and try again.
The page has expired due to inactivity. Please refresh and try again. laravel5.6 开发API使用apipost调用路由时 ...
- laravel5.5 The page has expired due to inactivity. Please refresh and try again.
报错: The page has expired due to inactivity. Please refresh and try again. 原因: 表单未添加CSRF验证,应添加{{ csrf ...
- laravel常见错误(一):The page has expired due to inactivity. Please refresh and try again.
背景知识: 最近工作上使用了laravel框架,这个常见错误系列会记录我在学习和使用laravel时遇到的一些问题的场景和解决方法. laravel文档:传送门 错误场景:我在web.p ...
- laravel 5.5 The page has expired due to inactivity. Please refresh and try again
在laravel框架中有此要求:任何指向 web 中 POST, PUT 或 DELETE 路由的 HTML 表单请求都应该包含一个 CSRF 令牌,否则,这个请求将会被拒绝 1.taiji/app/ ...
最新文章
- AtCoder Beginner Contest 198 (A ~ F)题解
- AIX 操作系统日常维护须知
- mysql事物日志工具_MySQL——常用工具和日志
- 将本地文件上传至Github【详细步骤】
- 【itext学习之路】--4.给pdf增加文本水印和图片水印
- linux终端怎样ise,Linux下ISE开发环境的安装zz
- C99中的变长数组(VLA)
- 定义枚举类型时指定其使用的大小 (C++,C#)
- hdu2844 Coins -----多重背包+二进制优化
- 微信小程序左右菜单mysql_微信小程序tab左右滑动切换功能的实现代码
- visual studio code写c语言是在include下有绿色的下划线提示not found
- 六石管理学:头目们为什么要忽略产品质量
- react在线文件_在线IDE开发入门之从零实现一个在线代码编辑器
- Android解析WindowManagerService(一)WMS的诞生
- leetcode 326 [easy]--- Power of Three
- 物联网(lot)特定场景最佳实践
- 如何修复 Windows 10 中任务栏消失的问题?
- Codeforces 106 Buns【多重背包】
- Power BI 中的货币换算
- 转行做程序员到底可不可行?转行前先考虑好以下几点
热门文章
- 批量保存西瓜无水印视频的方法步骤
- Mysql ERROR: 1253 解决方法
- 解决Win系统cad激活安装失败问题,AutoCad 2022 中文/英文正式详细安装教程
- 蔬菜类别二级计算机,国家标准:蔬菜分类.doc
- html魔方转动效果,简单说 用CSS做一个魔方旋转的效果
- 椭圆隐式方程和参数方程的互相转换
- 美通企业日报 | Gap在华门店总数突破200家;千禧一代环游世界的愿望超过买房...
- php弹幕反检测,【原理讲解附源码】找到B站弹幕的发送者
- 【计算机网络】计算机网络总结
- 玩转英伟达jetson系列(一)刷系统