Correct Cookie Config for Magento Site with Subdomains

cookiemultistoresession

The problem

A large site uses separate instances of Magento for different geographic regions so the businesses are isolated. Example:

  • site.com
  • north.site.com
  • south.site.com
  • east.site.com
  • west.site.com

Users may visit the root + regional sites, log in directly on a regional site, or log into (site.com) with their regional credentials (we have an authenticator + redirect in place).

Some are unable to login after previously being able to, and get no error feedback. We can replicate the fault which is having two cookies with the same name but different domains. Example:

  • Name: frontend, Domain: .site.com
  • Name: frontend, Domain: .north.site.com

Deleting the cookies resolves the issue in most browsers. The cookies seem to get stuck in some browsers and we're stumped other than waiting for them to expire which sucks for users.

What we tried

Initially our config was blank (as below) for all sites. This triggered the problems. As I understand it, we need to set the domain explicitly for all sites to ".site.com" so only one cookie can exist with that name/domain.

Does that resolve Magento's issue of not knowing which "frontend" cookie is the correct one — or is there a preferred config?

The Question

What is the correct cookie config in Magento's admin for a multi-domain setup?

See: "System > Config > Web > Session Cookie Management"

Magento cookie config

Best Answer

We had to do something similar recently:

  • Cookie Path: /
  • Cookie Domain: .site.com

That did the trick in our case.