简体   繁体   English

刷新表单时 CSRF 令牌不匹配 [暂停]

[英]CSRF token mismatch when refresh form [on hold]

I have a form using post method.我有一个使用 post 方法的表单。 The form submits successfully, but when i refresh (F5) the page i get this error.表单提交成功,但是当我刷新(F5)页面时出现此错误。 Error only browser IE.仅浏览器 IE 出错。 I researched and realized that when page is refreshed the $request->data is empty.我研究并意识到当页面刷新时 $request->data 是空的。

Note: anytime your page is loaded the CSRF token regenerate so you sending an old CSRF token to the new one will cause the error you are experiencing.注意:无论何时加载您的页面,CSRF 令牌都会重新生成,因此您将旧的 CSRF 令牌发送到新的 CSRF 令牌将导致您遇到的错误。 To solve this issue use redirect to redirect the page after every action on form submission an http request is made.要解决此问题,请在表单提交的每个操作后使用重定向重定向页面,然后发出 http 请求。 I hope this will help you我希望这能帮到您
check this检查这个
https://book.cakephp.org/3.0/en/controllers/middleware.html#cross-site-request-forgery-csrf-middleware https://book.cakephp.org/3.0/en/controllers/middleware.html#cross-site-request-forgery-csrf-middleware
https://book.cakephp.org/3.0/en/controllers/components/csrf.html https://book.cakephp.org/3.0/en/controllers/components/csrf.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM