Invalid Form Key. Please refresh the page. on magento admin login page

Viewed 49694

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

Invalid Form Key. Please refresh the page.

Magento was installed on a live server. I didn't change anything or add something to the database. Credentials are valid but we cannot log in. Also, I cannot login to the Magento downloader panel.

What kind of bug is this?

How can we solve this?

UPDATE!

From @DouglasRadburn link. The detailed explanation of the problem and the possible solutions.

https://magento.stackexchange.com/questions/98220/security-patch-supee-7405-possible-problems/98236#98236

Also similar to @Makwana Ketan answer

6 Answers

While working on localhost can not sign in or create Account - ubuntu OS

Invalid Form Key. Please refresh the page.

invalid key error solve

change this value in your php.ini file

max_input_time : 3600 max_input_vars : 200000 memory_limit : 2G

then go to your MySQL database

find core_config_data table

change base URL localhost to 127.0.0.1

than search path Like %...% domain then Go

change value localhost to 127.0.0.1 in front of web/cookie/cookie_domain ( path )

Go to your magento root directory then app -> /etc/ -> env.php open this file change value localhost to 127.0.0.1 ( 2 places in file )

go to browser press ctrl+shift+delete then check cache || cookie click on clear data

then run all command with sudo on magento root directory

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento setup:static-content:deploy -f

php bin/magento indexer:reindex

php bin/magento cache:clean

php bin/magento cache:flush

In my case, I was having this issue in my localhost after using production DB. I tried setting up max_input_vars but that didn't work. But clearing cookie settings such cookie path and domain works. So, go to stores -> configuration then General —> Web —> Default Cookie settings and remove values for cookie path and domain. Then clear magento2 configuration cache using bin/magento cache:clean config. This should resolve it.

Open your Browser, Clear cookies and session data. for safety clear your cache by bin/magento c:c, then refresh the browser page.

If the db is copied from the other server, just create a new admin user. The issue will resolve

Related