Sometimes I'm receiving this message below during the customer login after being changed the cookie domain through the admin panel.

Do you know why and when this message shows up?

Invalid Form Key. Please refresh the page

Magento2 Invalid Form Key. Please refresh the page


Magento 2 - What is the use of formkey

If you receive the error message, in cases where the form_key should still be valid, it is in most cases an issue in the cookie setup. If Magento can not find the form_key from your cookie, the form_key validation will fail. Issues for this could be an invalid cookie-domain, cookie-lifetime, ...


I solved it not just refreshing the caches invalidated but flushing all the caches possibles via admin panel through these 3 sections in the image below.

Do it mainly if you are using compiled configurations.

Magento 2 cache flush cookie domain issue

Make sure that you are using the right cookie domain configured.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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