I am using magento community edition 1.7.0.2.I am not able to login to back end of magento.I know this problem can be because of chrome not accepting cookies. But how to fix that please help. Thanks
- 3,122
- 6
- 45
- 87
- 7,630
- 21
- 105
- 159
-
Hi though I accepted the very non technical answer which worked for me as a beginner,Please go through other answers also. – Mukesh Apr 13 '16 at 15:12
9 Answers
If you enabled the https for the Magento admin panel, then make sure to set "NO" for the option "Use HTTP Only" under System->configuration->web->Session and Cookie Management."
If you have access to the database then open the table "core_config_data" and search for the Path "web/cookie/cookie_httponly" and set the value to "0".
Make sure to delete the var/cache folder. Now try to login to Magento admin panel. Mostly you can now. If not post your issue in this thread.
So this "Not able to login Magento admin panel" issue mostly relates to the Magento cookies settings. So don't get worried if you encounter this tiny issue. With the list of answers in this thread you can easily sort this out in a few minutes time.
- 12,568
- 14
- 72
- 106
- 1,540
- 16
- 21
-
1For anyone coming to this question, this should be the first answer you try. – Nathan Mar 25 '14 at 04:44
-
@Haijerome With your said way, don't you think that, that may lead a chance for XSS vulnerability. I am curious to know as I faced the same and was trying to go with your mentioned way https://blog.codinghorror.com/protecting-your-cookies-httponly/ – Anurag Khandelwal Feb 06 '17 at 11:43
There are two solutions for this, either one will work:
- Change the cookie lifetime configuration.Go to backend -> Sytem -> Configuration -> Web -> Session and Cookie Management Set cookie lifetime to 86400 and save it .

- Go to app/code/core/Mage/Core/Model/Session/Abstract/Varien.php file within your magento directory.
Find the code:
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath(),
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
);
or
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
and replace with
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()
//$this->getCookie()->getDomain(),
//$this->getCookie()->isSecure(),
//$this->getCookie()->getHttponly()
);
or
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath()
// 'domain' => $cookie->getConfigDomain(),
// 'secure' => $cookie->isSecure(),
// 'httponly' => $cookie->getHttponly()
);
After this save the file.
This so far is the best solution rather than changing the code elsewhere http://iamtheshadowonthesun.blogspot.com/2012/10/magento-cannot-login-to-admin-panel.html
Using phpMyAdmin, in your magento database, look for the core_config_data table and click it. Click the "Search" tab. Then on the "path" column set the operator to LIKE %...% and the Value to cookie and click the "Go" button to search.
After searching, set the value of web/cookie/cookie_path, web/cookie/cookie_domain, web/cookie/cookie_httponly, and web/browser_capabilities/cookies to NULL
- 410
- 4
- 13
what worked for me is what Haijerome, unfortunatelly I can't login into the backend to change the config. This is what I execute whenever I install a new fresh magento:
insert into core_config_data(scope, scope_id, path, value) values("default", "0", "web/cookie/cookie_httponly", "0");
then:
rm -Rf var/cache/mage--*
- 1,876
- 17
- 18
Our Chrome users were unable to add items to their cart... changing the Cookie Lifetime to the recommended 86400 fixed it.
Magento Community 1.7
Thank you!
Jeff
- 21
- 1
the problem is that chrome isnt storing the login cookie, this can be seen by looking at the cookies in chrome | settings | content | advanced | all cookies and site data
there's probably a number of reasons why this can happen, cookie lifetime for sure is one of them..
personally I encountered this problem when running magento in localhost / on a virtual machine and connecting from a browser on the same machine. specifically the problem seems to be that chrome will not store cookies if the domain name is not qualified. so if your domain name is 'http://localhost/magento' or 'http://somename/magento' chrome will not store the cookie and consequently you will not be able to login
here's the fix:
to keep this simple i'm sticking to the example where magento is running on localhost. the same trick will work if magento is running on a vm and you're accessing from localhost, but you need to modify the hosts file on both guest os and client in such a case. (and remember that the guest ip can change so from time to time you need to update the hosts file on the host)
first choose your domainname. it's only in local so you dont need to register. i'm choosing 'dansmagentodev.com'. then in magento | system | web modify baseurl in both secure and unsecure to be http://dansmagentodev.com/magento/
next, in the same place, modify the session cookie management 'cookie domain' to be 'dansmagentodev.com'
next we need to configure your system to know that dansmagentodev.com is really localhost. we do this via the hosts file. on windows this file is in C:\Windows\System32\drivers\etc\hosts. your virus checker will probably try to stop you modifying it (for good reason, disable virus checker while you make the modification). then add the line 127.0.0.1 dansmagentodev.com
And now log in from chrome.
- 689
- 5
- 13
-
1just in case; if you break your configuration doing this (which can happen if the url you enter into magento | system differs from that in your hosts file) then you can fix by manually editing the sql tables, look in core_config_data – dancl Dec 19 '12 at 22:54
One simple solution is to do the installation using Opera browser and use it to log in because it saves the cookies itself. It works!
- 58
- 3
My problem was the fact that the server I was running was an Ubuntu fresh install with very little server maintenance configuration.
It had not updated it's date & time and it was 3h behind.
This made cookies received by Chrome to look as if they were already expired so Chrome discarded them.
- 15,848
- 2
- 33
- 51
If on firefox works. Then the problem is cookies on chrome, try to clear your chrome's cookie.
- 3,122
- 6
- 45
- 87
-
4I tried your solution but it does not help.It is working on firefox. Thanks for suggestion – Mukesh Sep 08 '12 at 07:29
-
-
1if you run magento on localhost, Go to app/code/core/Mage/Core/Model/Session/Abstract/Varien.php file within your magento directory. session_set_cookie_params( $this->getCookie()->getLifetime(), $this->getCookie()->getPath() //$this->getCookie()->getDomain(), //$this->getCookie()->isSecure(), //$this->getCookie()->getHttponly() ); – Josua Marcel C Apr 11 '13 at 04:13
-
3Better not to comment in core files.create local copy of file then comment the above lines in Varien.php – Mukesh Jun 04 '13 at 07:23