0

The error "Invalid Form Key. Please refresh the page." appears when submitting the contact form.

I just don't know how to handle this. :( In my opinion, this must not even be supposed to happen. How can I get rid of this error?

enter image description here

5
  • You should check the code. I once debug in a site that they include a custom code and that caused the error.
    – Jimmy
    Commented Apr 13, 2021 at 6:22
  • The thing is that the page is generated by module-contact and that module was not touched. There is no code in that module to generate that error. Commented Apr 13, 2021 at 15:21
  • I don't say that you modified the code, just an example. You never know what's the issue until you debug the code, or undo what you had done (before the error happen)
    – Jimmy
    Commented Apr 13, 2021 at 16:01
  • I will try. Thank you for your time! Commented Apr 13, 2021 at 16:14
  • 1
    Thank you @Jimmy for your suggestion! I found the solution and solve the problem! Commented Apr 14, 2021 at 15:35

1 Answer 1

1

The problem was the missing line inside contact page as seen in the page's source code:

enter image description here

My solution was to overwrite the form.php file of the contact module inside my custom theme so it could generate the line marked in the above picture.

enter image description here

After that I ran the command: ./magento setup:di:compile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.