Categories

Featured templates

Magento. Can’t login to admin panel

Chris Diaz December 21, 2011
Rating: 5.0/5. From 2 votes.
Please wait...

This tutorial shows how to resolve the Magento admin panel login issue.

It’s a common issue: you are trying to login to the Magento admin panel, typed your username and password, clicked Login button and nothing happens. The page refreshes and that’s all. No error or any other messages.

This is caused by the cookies issue. In some cases Magento can’t store them. Let’s see how the issue can be resolved.

Using localhost (WAMP, XAMP, AppServ etc)

If you are running Magento on local server using the specific server applications (listed above) try to replace localhost in the website URL with ‘127.0.0.1’. In other words link to the Magento admin panel login page will be ‘127.0.0.1/magento/admin’

If this doesn’t help please proceed to other solutions

Edit Varien.php file

Open Magento installation directory and go to the app\code\core\Mage\Core\Model\Session\Abstract’ folder. There open ‘Varien.php’ file with your editor (Adobe Dreamweaver, Notepad ++ etc).

Depending on your version of Magento the code can be different so I’ll show you several cases.

Magento 1.4.x

In the Varien.php file locate the code:

 if (!$cookieParams['httponly']) {
  unset($cookieParams['httponly']);
  if (!$cookieParams['secure']) {
  unset($cookieParams['secure']);
  if (!$cookieParams['domain']) {
  unset($cookieParams['domain']);
  }
  }
  }
  
if (isset($cookieParams['domain'])) {
  $cookieParams['domain'] = $cookie->getDomain();
  }

And comment it. Type /* before the code and */ after. Or just replace it with the code below:

 /*if (!$cookieParams['httponly']) {
  unset($cookieParams['httponly']);
  if (!$cookieParams['secure']) {
  unset($cookieParams['secure']);
  if (!$cookieParams['domain']) {
  unset($cookieParams['domain']);
  }
  }
  }
  
if (isset($cookieParams['domain'])) {
  $cookieParams['domain'] = $cookie->getDomain();
  }*/

Magento 1.5.x and Magento 1.6.x

In the Varien.php file locate the code:

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

and replace with

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

Then comment the code:

 if (!$cookieParams['httponly']) {
  unset($cookieParams['httponly']);
  if (!$cookieParams['secure']) {
  unset($cookieParams['secure']);
  if (!$cookieParams['domain']) {
  unset($cookieParams['domain']);
  }
  }
  }
  
if (isset($cookieParams['domain'])) {
  $cookieParams['domain'] = $cookie->getDomain();
  }

the same way as for the Magento 1.4.x (please check above)

Magento Website Templates
This entry was posted in Magento Tutorials and tagged admin, login, Magento, unable. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket