Problem:
I had a new installation of magento. But I was unable to login as an administrator. I went to the admin login page, entered correct username and password but was redirected to the same login page. I could not enter the dashboard page. Error message is displayed when I enter wrong username or password. But nothing is displayed and I am redirected to the same login page when I insert correct username and password.
Solution:
Modify Magento code. Open app/code/core/Mage/Core/Model/Session/Abstract/Varien.php. Comment out the
lines 80 to 83. The line number may vary according to the Magento version. These lines are present somewhere near line 80. You have to comment the comma (,) in line:
$this->getCookie()->getPath()//,
NOTE: Editing Core File is NOT a good practice. It is better to make a local copy of core file. Copy app/code/core/Mage/Core/Model/Session/Abstract/Varien.php to app/code/local/Mage/Core/Model/Session/Abstract/Varien.php and edit the local file.
// set session cookie params
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()//,
//$this->getCookie()->getDomain(),
//$this->getCookie()->isSecure(),
//$this->getCookie()->getHttponly()
);
Update (For Magento 1.4.*) and higher versions
In Magento 1.4 and higher versions, you have to comment code below which is present around line 80 to 100 in
app/code/core/Mage/Core/Model/Session/Abstract/Varien.php.
/* 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();
} */
NOTE: Editing Core File is NOT a good practice. It is better to make a local copy of core file. Copy app/code/core/Mage/Core/Model/Session/Abstract/Varien.php to app/code/local/Mage/Core/Model/Session/Abstract/Varien.php and edit the local file.
This might be a quick fix. However, it is better to find out the exact cause of your problem and then try fixing it. There can be different reasons behind this problem of admin login. Here is a proper answer to this issue: http://magento.stackexchange.com/a/26083/1883
Hope it helps.
Thanks.