Magento – Multi Store Cookie Issue

cookiemagento-1.9multidomainmultistoresession

We have two stores in our Magento 1.9 installation: a retail website, coolstuff.com (no www prefix) and a wholesale website, dealer.coolstuff.com. Following the launch of our website with HTTPS forced on for all pages, we are having issues only on the wholesale website (i.e., subdomain dealer.coolstuff.com) that are seemingly session/cookie related based on what I've found researching.

It seems as though most topics on this subject desire the customer's session to be persisted across both stores (e.g., regional stores, such as north.mysite.com and south.mysite.com). This is not our desired functionality— we run two separate stores with separate customer bases and separate pricing, so therefore you should be able to be logged into coolstuff.com with one account, and dealer.coolstuff.com with a different account.

My system configuration under 'General -> Web -> Session Cookie Management" is as follows:

Scope: coolstuff.com

Cookie Path: /
Cookie Domain: coolstuff.com

Scope: dealer.coolstuff.com

Cookie Path: /
Cookie Domain: dealer.coolstuff.com

I'm noticing in my Chrome Resource Management that I have a frontend cookie for both domains with the same session id and the Domain is prefixed with a . e.g., .coolstuff.com and .dealer.coolstuff.com both have a value of tfbjsnm5df2o2hqcofbh9r3s74 but different expiration dates. This seems like a configuration issue, but I just can't seem to get it figured out.

What am I doing wrong here? I feel like the issue is that the browser isn't sure which cookie to use? Would a www prefix on our retail website (and corresponding change to cookie configuration) resolve this? I'm really scratching my head here, any input would be great!!

Best Answer

The issue is you're creating a cookie that doesn't have an explicit sub-domain. Adding the www subdomain to coolstuff.com and clearing your cookies should fix the issue.

When you visit dealer.coolstuff.com it's sending along the cookies for coolstuff.com, loading the same session id and then generating a 2nd cookie for dealer.coolstuff.com