Thursday, July 29, 2010

Cannot login on Magento backend using Firefox



I encountered this problem whenever I'm installing a new Magento Shop in my localhost, so it's best to post it here..

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

Solution
1. If you don't want to dig in the Magento Core files you can set the url to 127.0.0.1/path-to-your-magento-directory/ at the start of your installation. <THAT'S IT!>

2. BUT... if that doesn't work, you should dirty your hands :) after installation go to this path in your magento folder app/code/core/Mage/Core/Model/Session/Abstract/Varien.php open this file with a text editor or Dreamweaver...

Find this phrase "session cookie" by pressing CTRL+F and you will see this code from line 77 to 94

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

if (!$cookieParams['httponly']) {
unset($cookieParams['httponly']);
if (!$cookieParams['secure']) {
unset($cookieParams['secure']);
if (!$cookieParams['domain']) {
unset($cookieParams['domain']);
}
}
}

----------------------------------------------------
I just commented the lines like this
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath() /*,
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()

*/ );

/* if (!$cookieParams['httponly']) {
unset($cookieParams['httponly']);
if (!$cookieParams['secure']) {
unset($cookieParams['secure']);
if (!$cookieParams['domain']) {
unset($cookieParams['domain']);
}
}
}
*/

That's it! Then try to login again..


No comments:

Post a Comment