Fix for Can’t login to admin after magento installation

January 13th, 2010 Posted in Open Source

While installing Magento Fresh copy to our local machine using xampp, wamp, mamp  or any of the Lamp Platform we will usually cant login to the admin  panel. It will not show any error on the user account but will return to the same login page after we submitted the page.

The problem occurs because magneto could not store cookies. We run it as localhost and localhost is not true domain but to store cookies we need a domain. That’s why login stops without saying any word.

When I tried this  in different browsers  I found that we can login the admin page in safari without doing any change but can’t login using  firefox or Internet explorer.  We can solve the problem in many ways.

Solution 1. Creating a virtual host

We can solve the problem by simply setting up a virtual host like http://magento.local I fixed the problem by this method since it seems to be very easy and reliable.
For setting up a virtual host for magento just edit the httpd.conf and add the following line to the end of the file

NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1 >
ServerName magento.local
DocumentRoot “D:/wamp/www/magento”
</VirtualHost>

Then edit the /etc/hosts in linux or C:\WINDOWS\system32\drivers\etc\hosts in Windows and add the following to the file

127.0.0.1 magento.local

Solution 2. Change the localhost url to IP

Change http://localhost/magento/index.php/admin to http://127.0.0.1/magento/index.php/admin. But this will not work for all the cases

Solution 3. Comment some line of code

Edit app\code\core\Mage\Core\Model\Session\Abstract\varien.php and Comment the following lines (may be at line 78…);

$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()

Leave a Reply