Cannot login in admin even after entering the correct username and password

After setting up the Magento Community Edition (ver. 1.7.0.2) on my local machine for development, I found that I am not able to login in to the admin section. I entered correct username and password but  it redirected me back to the same admin login page with no error message. If I enter incorrect login details it does give me the error “Invalid User Name or Password”. I am using Windows Xp and Xampp Version 1.8.1 (Apache 2.4.3, MySQL 5.5.27, PHP 5.4.7) and I was accessing my Magento admin using url “http://locahost/magento/index.php/admin”.

One of my friends faced the issue that he was able to login in Firefox  but not in Chrome.

Here are my findings to fix this issue:

1. Use 127.0.0.1 instead of localhost when installing on local machine.

When installing Magento on your local machine enter the IP 127.0.0.1 instead of localhost in the base URL e.g: http://127.0.0.1/magento/

Magento Install

If you have already installed Magento then you can update the “base URL’s”  in `core_config_data` table of your database.

Core Config Data

 

2. Setup a virtual host and access your local Magento website like on a real domain.

You can setup a virtual host as described at http://www.techawaken.com/creating-virtual-hosts/.  After setting up a virtual host you need  to make an entry in the hosts file. In Windows Xp the file is located at “C:\WINDOWS\system32\drivers\etc”.  The “hosts” file already has sample entries but commented. You need to enter IP address followed by a tab space and then the hostname in a new line in the hosts file; example below


127.0.0.1       mymagentowebsite.com

 

3. Override the “app/code/core/Mage/Core/Model/Session/Abstract/Varien.php” file in local development environment.

Copy the file  “app/code/core/Mage/Core/Model/Session/Abstract/Varien.php” to “app/code/local/Mage/Core/Model/Session/Abstract/Varien.php” and then comment out the lines 89-91 as below:


// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path'     => $cookie->getPath(),
// 'domain'   => $cookie->getConfigDomain(),
// 'secure'   => $cookie->isSecure(),
// 'httponly' => $cookie->getHttponly()
);

NOTE: You do not need to override this file when deploying code to production.

Comments

Leave a Comment

Back to top