In the end I found this issue related to server configuration. The staging site was on a server with Varnish installed.
Varnish was set to ignore the staging site url in the configuration, but it was still interfering with the cookie creation somehow - despite not otherwise caching the site in any way.
Using a non-standard port, to bypass Varnish completely, immediately resolved the issue.
I'm still investigating why Varnish caused this issue - if and when I have more information I will update this answer.
Make sure to setup your cookie domain name exactly same as how you access from browser(with or without www) And check the following settings in
Magento admin under System > Config > Web
And update like following
Cookie Lifetime: 33600
Cookie Path: /
Cookie Domain: www.yourdomainname.com
Use HTTP Only: No
Cookie Restriction Mode: No
This should fix your problem(Clear your browser cookie for one last time and check)
If this doesn't work still your server environment and session/cookie saving doesn'tmatch like magento needed. So you may need to un-comment domain settings in
app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
Around #95 from
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
To
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
// 'domain' => $cookie->getConfigDomain(),
// 'secure' => $cookie->isSecure(),
// 'httponly' => $cookie->getHttponly()
);
Note:
You can extend this core file to your local and do this and you need to uncomment only the domain,secure,http params not entire cookie params.
Best Answer
I know that you already inserted the formkey, but I had the same problem and I discovered that I was using the formkey in the wrong way.
1 - Make sure that you use this code to insert the formkey:
2 - The code should be right after the line:
3 - Make the change in the right files:
or, if you are using a custom theme:
Good luck :)