I am just a newbie to the magento. I have installed magento on my localhost. After all the setup when I used the admin page to login I can't able to login in chrome browser even with my right username and password. But when I am trying to login in firefox there is no problem. So can some one really help me here to solve the problem?
-
1Follow this link [Why I can not login to magento backend using google chrome][1] [1]: stackoverflow.com/questions/12328366/…– MukeshMar 19, 2013 at 5:05
-
You can get the answer from [HERE][1] [1]: magento.stackexchange.com/questions/6426/…– KhAn SaAbJun 20, 2014 at 20:15
-
I'm facing this same issue, check my question please magento.stackexchange.com/questions/85958/…– JóniOct 12, 2015 at 11:58
15 Answers
I think there is the problem with session cookie
with the chrome browser.
So just go through this directory
/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
file
and comment out the line from 85 to 92 in magento (1.7.2 for my case). Like this
// session cookie params
/* $cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
*/
after that try to make login from your backend. Hopefully you can make login with chrome. This will definitely help you. If you are still facing the problem then just reply me.
-
1I solved the login issue in my live site using this answer. Is it right to use this solution in live server or this solution is for localhost only? Apr 3, 2014 at 7:11
-
9Files in app/code/core should never be modified, only extended. If you were to ever upgrade your site, your changes will be overwritten. Dec 11, 2014 at 15:53
-
1I was experiencing this issue on a client's site as well, and filling in the Cookie Domain resolved the issue. I also filled in "/" (no quotations) for the Cookie path. Dec 11, 2014 at 16:04
-
6I don't know why this answer is getting such a high score, it's dead wrong to do this. Just change your cookie path like Meogi mentioned. Apr 2, 2015 at 10:59
-
1Never ever makes changes to Magento Core files. You just need to update cookie domain. This is a good resource blog.philwinkle.com/i-cant-login-to-magento-admin Apr 6, 2015 at 7:46
try using 127.0.0.1 when you set up magento in localhost. I have also encounter same problem, that's the solution a have made and it works fine.
-
3This work for me, and I prefer this, becouse no need to change any things in the code. Aug 19, 2013 at 12:02
-
2I think this is the correct answer instead of commenting out the core files.. Thank u for ur solution Apr 22, 2015 at 11:02
From System -> Configuration -> General -> Web
, set Unsecure and Secure Base URL with IP Address. And try to login again.
GO to File at this location :- app\code\core\Mage\Core\Model\Session\Abstract\Varien.php
And commenting out the following (it's lines 85 to 102);
// 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']);
// }
// }
//}
And use your credentials to logged in. Hope that should works for you!!!
Magento sees cookie_domain
on core_config_data
table when you try to login. If it is diffrent from your domain, you can not enter your admin panel, just refreshing the page, no error comes up.
Open core_config_data
table from your database and search or filter the path
column for web/cookie/cookie_domain
and change it to null or your domain.
When it happens with me, the problems was because I make a directory move but the .HTACCESS files of main content was not moved to new path.
Check if your .htaccess file is in main content.
-
you answer is right, and I think that modifying the .htaccess file better than modifying the code of magento core– SpartanNov 4, 2015 at 13:35
just apply the comment here... file location : \app\code\core\Mage\Core\Model\Session\Abstract\Varien.php
/*
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
*/
login as admin with internet explorer or other broswer. flush all caches.. And you will be able to log in using chrome . You can login in without having to modify any code
If you are using Magento 1.9, the file must be slightly different: /app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
$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 have tried the newuser solution and that worked perfectly. It'd be great if you can provide some more information about your answer. Thank You. May 11, 2015 at 10:35
It’s also important that you have a form key present, otherwise your form won’t get processed.
<?php echo $this->getBlockHtml('formkey'); ?>
This is my simple solution that helped me in the same situation. Try it for 60 seconds of your time.
In Google Chrome, in Developer Tools (right-click on any page element and select Inspect Element), go to the Resources -> Cookies tab. Delete the extra cookie for your original domain. Or set your base url domain to something else, or change the port.
As the accepted answer pointed out, the problem lies with chrome when accessing Magento on a localhost. Wrap the code in theapp/code/core/Mage/Core/Model/Session/Abstract/Varien.php
with the following snippet, and the session parameter array will be only reset if you are on localhost (IP'127.0.0.1' or '::1').
// SNIPPET Part 1: add this before the original array definition
// -----------------------------------------------------------
if(in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
$cookieParams = array();
} else {
// here comes the original code, thats what you should
// look for but not touch
// -------------------------------------------------------
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
// SNIPPET Part 2: add the closing bracket
// ------------------------------------------
}
I have Magento ver. 1.14.2.1
changing varien.php did not solve my problem.
entering 127.0.0.1
instead of localhost
in Dashboard configuration Web Base URL solved my problem.
I can still enter localhost in the url and it automatically redirects it to the ip format url.
For Magento 2
Instead of localhost on your WAMP please use http://127.0.0.1
{folder path}\magento2\vendor\magento\zendframework1\library\Zend\Session.php
Go to & Comment as mentioned
public static function rememberUntil($seconds = 0)
{
if (self::$_unitTestEnabled) {
self::regenerateId();
return;
}
$cookieParams = session_get_cookie_params();
session_set_cookie_params(
$seconds,
//$cookieParams['path'],
//$cookieParams['domain'],
//$cookieParams['secure']
);
// normally "rememberMe()" represents a security context change, so should use new session id
self::regenerateId();
}
Having session/cookie problems with webkit browsers (e.g. Chrome) in Magento? Go to System -> Configuration -> Web -> Session Cookie Management and set “Use HTTP Only” to no. Have fun.
-
1This sounds like it involves disabling XSS protection across your entire browser. That's kind of a bad idea. Oct 9, 2015 at 1:58