Magento cookie bug with WebKit based browsers
문제
There is a reasonably common & well documented cookie-related bug/issue with Magento and Chrome (looking at the others' issues - possibly WebKit and IE at times). Whether this is due to a common Chrome extension/setting or incorrect web server setting - I do not know.
I'm on OS X 10.8.2 running CentOS 5.8 via VirtualBox. More often than not, for me to login to a Magento admin, I need to set the HTTP Only setting in the Magento admin to 'No'. Before I do this, I am not able to login via Chrome - other browsers do not seem to have this issue for me.
Now I've come across a new (but probably the same) issue while making an extension - I am able to read cookies via Chrome but not set them. There were no issues with using Firefox. To make sure it's not my Chrome, I've performed a fresh install by deleting all user data and profiles but the issue persists. Perhaps I should set the cookies via JS only for this extension.
Nothing out of the norm with the cookie setting code:
$cookie = Mage::getModel('core/cookie');
$cookie->set('cookiename','cookievalue',99999);
해결책
Don't develop using localhost
as your domain name. I typically use apache to setup a fake custom site at a domain like magento.dev
, and then add
127.0.0.1 magento.dev
to my hosts file. Beyond working around the cookie problem, this also lets me have an infinite number of sites running locally.
다른 팁
Is your server time and computer time correct? This causes the majority of cookie issues with Webkit based browsers - whereas IE and FF are far more tolerant (ignorant).
Turns out that Chrome interprets your custom web address differently from other browsers. I had a custom top level domain for my local installations but when this was changed to .com
the issue was resolved and now it's set as .local
(I was using .fk
previously)