Unable to log in your Magento Admin Panel from backend?
What you should do firstly is to check again your Magento backend to see if you are on the right URL links, then check if you have entered username and password correctly. Still not reach the Magento admin site but redirected to the same page display while frontend pages, git and database all seem to run well? Then you might take a look at some brief explanation for this inconvenient issue and some instruction to deal with this issue.
There are 2 main possible reasons for this problem:
1. Web browser’s cache has not been removed:
Instead of showing you the finest version of the backend, the browser may load the stored version of the link which might have troubles previously. Similarly, it might appear on the screen that: "Invalid Form Key. Please refresh the page."
→ How to solve: You need to delete cache from your magento_root/var/cache and remove cookies from your browser by using a private browser. Also, you can press responsive key combination to force reload on your operating system, which includes:
- Windows: Ctrl + F5
- Mac/IOS: Command + R
- Linux: Ctrl + F5
If it is still not working, it may be because the cache not had been set up properly in web/cookie/cookie_domain and web/cookie/cookie_path values in core_config_data table. Then for this, you could use: rm -rf var/cache/ to remove cache. However, for Magento 2, you should use php bin/magento cache:flush to avoid delete all the folder /var. Here are examples for both versions:
- Magento 1.x
- Magento 2.x:
2. The host that you are accessing through your computer, called localhost, has created the wrong cookies:
Magento checks if the hostname is a real domain name, and if it isn’t, it automatedly fails to create the right cookies. That means when Magento calls session_start() - the session identifier cookie never gets created. As a result, information cannot be passed from page to page.
The login procedure is actually successful but the next request doesn't know about it, hence user is redirected back to the login screen.
→ How to solve:
- Firstly, you have to edit your hosts file for this: Change the IP-address to http://127.0.0.1/ to access Magento.
- If the solution above doesn’t work, follow the steps below to disable the wrong cookies:
Step 1: With those who are using Magento 1x, go to app/code/core/Mage/Core/Model/Session/Abstract/Varien.php file in your Magento directory.
Step 2: Find the code:
session_set_cookie_params
$cookieParams = array('lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
and replace this by:
session_set_cookie_params
$cookieParams = array('lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
// 'domain' => $cookie->getConfigDomain(),
// 'secure' => $cookie->isSecure(),
// 'httponly' => $cookie->getHttponly()
);
Step 3: Save the file. Now you will also have to clear the cookies by using a private browser or reload key combination to let the browser update the edited version. Then try loginning to your admin again.
One last reminder is that you should not bookmark the admin URLs with wrong form keys or leave them open in a tab. It can bring the issue back. Always remember to bookmark the clean Admin panel URL for later convenience. Although it seems to be a very annoying problem when you are unable to login your Magento Admin link at backend, it could be tackled in few minutes just like a piece of cake!
Otherwise, you can get direct support to fix the problem here.
Hope that you find this information useful! If you need any help with Magento services or want to build a Magento e-store from scratch, feel free to contact us.