Tuesday, April 24, 2012

Magento 1.6 cannot login on admin



I have a sample Magento 1.6.2 installation wherein I test sample codes, install/test extension and also it acts as a quick reference whenever I'm not sure of anything on the admin area.
As you have guessed I tried loggin in one fine day and pooof! I can't login.. Tried almost anything (eg. clearing cache, session, locks ... using other web browser) but it still wont log me in..

Tried searching for a solution and thank God I found one on phpgenious..
It says that this is a cookie problem because Magento cannot create a cookie on your site, so here's the solution. (this solution worked for me..)

COPY app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on app/code/local/Mage/Core/Model/Session/Abstract/Varien.php (so that it will not be overwritten when you upgrade)


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

and replace it with:


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

What we did here is we disabled the cookies check that Magento do when we try to login.. This should not be used on live site because cookies will work if you have a true domain.

No comments:

Post a Comment