Fixing Magentos login error on localhost

To solve the login problem that seems to occur when Magento is installed on localhost goto:

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

search and comment these lines out (around line 85):

/*      // 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’]);
}
}
}
*/

Then clear the cache and login again.

It may also help to change the database entries in core_data_config to 127.0.0.1 instead of localhost