cancel
Showing results for 
Search instead for 
Did you mean: 

"Invalid Form Key. Please refresh the page." issue

"Invalid Form Key. Please refresh the page." issue

Randomly I cannot login to frontend Magento default installation with the test account "roni_cost@example.com".

 

Then I get the error message : "Invalid Form Key. Please refresh the page."

 

I tried the suggested solutions of :

- Increasing the PHP max_input_vars to 100000

- Delete from the database table "core_config_data" the line with "path" = "web/cookie/cookie_domain"

- Clear the cache

 

But I still have this issue not being able to login, but if I try to login on another computer it is working!

 

Then this seem to be related to my own cookies or session.

 

I tried to delete all my cookies on my Firefox navigator and it is the same error again when trying to login.

 

Can someone help me pinpoint the problem?

 

7 REPLIES 7

Re: "Invalid Form Key. Please refresh the page." issue

I have noticed that if I open the login page in a "Private Navigation Window" in Firefox, it is login properly!

 

So the issue must be with cookies or session!

Re: "Invalid Form Key. Please refresh the page." issue

Hi @rejeanrege0421 

 

Please check below solutions  for this issue as this is a general issue.

 

Invalid-form-key-Magento-2 

magento-2-invalid-form-key 

 

Hope this helps.

 

Problem Solved? Click kudos & accept it as solution. 

Re: "Invalid Form Key. Please refresh the page." issue

Thank you shubham_khandelwal1 for trying to help!


I already have tried the solution here "Invalid-form-key-Magento-2".


I have checked and found 22 "Session.php" files in my Magento directories, but none had a path like "app/code/local/Mage/Core/Model/"...


Regarding the solution here "magento-2-invalid-form-key", it is more related to the creation of a product with multiple attributes. The solution is no help for me.


The odd thing about this situation is that even if I delete my 123 cookies, my 7 session vars and my 10 local vars in Firefox, I still get the same error message. But if I open a "Private Window" in Firefox, I am able to login!


Another thing is that I can login the next morning when I restart my PC. So this situation seem related with cookie or session and is more from the Magento 2.3.4 side than the Firefox side.


Thank you for your suggestions, I really hope to find a solution to this issue before putting my Magento application in Production mode.


Rej

Re: "Invalid Form Key. Please refresh the page." issue

If it could help to troubleshoot my problem, I discovered that I had 2 "form_key" cookies in Firefox, here is the list of 4 of these cookies with different domain and path :

 

form_key :"sSnNCudTbotDvMEP"
Domain :".entrer.ca"
Path :"/magento2"

 

form_key :"sSnNCudTbotDvMEP"
Domain :"entrer.ca"
Path :"/"

 

PHPSESSID :"k2245epi8den4ak9ec100j48n2"
Domain :".entrer.ca"
Path :"/magento2"

 

store :"french"

Domain :"entrer.ca"
Path :"/magento2/"

Re: "Invalid Form Key. Please refresh the page." issue

Hello,

I have the same issue as the one you have.

 

I'm curious if you have found a solution to it yet?

 

Thanks in advance 

Re: "Invalid Form Key. Please refresh the page." issue

Are you running on localhost or live server?
If you are running on localhost, maybe Base URL on Localhost not regconize by Magento 2 system

If you are facing this issue on Localhost, probably your site are using localhost as base URL instead of 127.0.0.1

This may make fault in Magento 2 cookie system, which causes Invalid Form Key. Please refresh the page error.

php bin/magento setup:store-config:set --base-url="http://127.0.0.1:8080/"
If you are running Magento 2 on live server, edit the following values in php.ini
max_input_time : 3600
max_input_vars : 100000
memory_limit : 2G
Hope this helps

Re: "Invalid Form Key. Please refresh the page." issue

I have a weird situation again that I have encountered on Magento. A few hours ago, I successfully logged in to admin dashboard. After I logged out and restart my pc and tried to log in again. I got an error

FirstCallOnline