[contact-form-7 id="24078" title="Feedback EN"]

Featured templates

Magento. Can’t login to admin panel

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)

  • ircsome

    make sure that you have set configuration options correctly before resorting to this … see http://www.magentocommerce.com/wiki/modules_reference/english/mage_adminhtml/system_config/edit/web section on Session Cookie Management :)

  • jason

    It’s worked great!

    • Abdul Basit

      also workd on magento1.7.0.2

  • Cool! Fixed on ver 1.6 successfully. thanks!

  • ians

    work perfectly with magento 1.5. good job. thanks

  • Amit

    Thanks Pal. This helped me!

  • Steven Yonts

    Great thanks man it worked!!

  • Dilip

    Really appreciate. Thanks… Great :)

  • i think it happens in the linuxbased system only. i had install it in the windows but it works fine.

  • Worked like a charm, thanks!!!

  • Aadil

    Really thanks allot ,
    After a long struggle i work’s now …

  • karan

    thanks a lot it works for me.. :)

  • dhananjay singh

    great works dear