1

On a shared machine, I have two sites running: example.com and staging.example.com. I have a problem where I can't log into the staging admin due to cookie issues.

If I clear all the cookies, I can log into the staging admin, and subsequently the main admin as well, but I get kicked out of staging. Inspecting cookies, they're both set to .example.com. I've tried all possible combinations of cookie domains for the respective site, but none seems to work.

This solution has a similar problem that he solved by forcing his main site to go to www.example.com and setting appropriate cookies (I'm guessing cookie domain values .www.example.com and .devsite.example.com in his case). Is there any other way to make both of these sites work properly in the same browser without the www addition or hacking the code?

2 Answers 2

3

You should set a different cookie domain corresponding to each subdomain you would like to use. You can set these in the Session Cookie Management in the backend, on store level.

More info here: https://stackoverflow.com/questions/31640990/magento-cookie-settings-for-subdomain

1

The problem is that when you use a top level example.com as the cookie domain on your production site and then log into your production admin and later try to log into your staging admin, Magento on your staging site is trying to load the session using the adminhtml cookie from your production site. enter image description here

The above example shows the frontend cookie conflict, which is the same issue as you're having with the adminhtml cookie. Your browser is sending the production adminhtml cookie to your staging server and Magento is trying to load the adminhtml cookie from your production site which doesn't exist. On your production admin, set the cookie domain for the default configuration to www.example.com and that should solve it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.