Magento - Can't login to admin in localhost

Posted by Damodar Bashyal on June 17, 2012

 

I am currently working on magento version 1.3.2.4. When i login to admin, it looks like i have entered proper username and password because it doesn't show any error like "Invalid username or password". When i try with fake login I do get error. Even i am not getting any error it stays on the login page.

So, I had to go through code and comment out few lines after which I was able to login and access admin again.

app\code\core\Mage\Core\Model\Session\Abstract\Varien.php line 77: original:

// set session cookie params
session_set_cookie_params(
    $this->getCookie()->getLifetime(),
    $this->getCookie()->getPath(),
    $this->getCookie()->getDomain(),
    $this->getCookie()->isSecure(),
    $this->getCookie()->getHttponly()
);

Commented out three lines:

// set session cookie params
session_set_cookie_params(
    $this->getCookie()->getLifetime(),
    $this->getCookie()->getPath() /*,
    $this->getCookie()->getDomain(),
    $this->getCookie()->isSecure(),
    $this->getCookie()->getHttponly()*/
);

As, I am upgrading magento from old community to enterprise 1.11 version. When i needed to login to admin of enterprise version, i got same issues. But this time code was different, so this is what i needed to do to access magento enterprise admin again.

app\code\core\Mage\Core\Model\Session\Abstract\Varien.php change:

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

to:

if (isset($cookieParams['domain']) && !in_array("127.0.0.1", self::getValidatorData())) {
    $cookieParams['domain'] = $cookie->getDomain();
}

NOTE: You may not need to update those codes if your admin login was working previously (or works in another browser e.g. google chrome, firefox etc). Just go to cookie settings in your browser and delete all the previous cookies. This worked for me.

 
not published on website


QR Code: Magento - Can't login to admin in localhost