The CSRF token is invalid. Please try to resubmit the form

后端 未结 15 1486
粉色の甜心
粉色の甜心 2020-11-28 10:38

I\'m getting this error message every time I try to submit the form:

The CSRF token is invalid. Please try to resubmit the form

相关标签:
15条回答
  • 2020-11-28 11:10

    I had the same error, but in my case the problem was that my application was using multiple first-level domains, while the cookie was using one. Removing cookie_domain: ".%domain%" from framework.session in the config.yml caused cookies to default to whatever domain the form was on, and that fixed the problem.

    0 讨论(0)
  • 2020-11-28 11:12

    You need to remember that CSRF token is stored in the session, so this problem can also occur due to invalid session handling. If you're working on the localhost, check e.g. if session cookie domain is set correctly (in PHP it should be empty when on localhost).

    0 讨论(0)
  • 2020-11-28 11:14

    I had this issue with a weird behavior: clearing the browser cache didn't fix it but clearing the cookies (that is, the PHP session ID cookie) did solve the issue.

    This has to be done after you have checked all other answers, including verifying you do have the token in a hidden form input field.

    0 讨论(0)
提交回复
热议问题