How to allow cookie to span multiple subdomains?

Moderator
Von United States
Mitglied seit Okt. 2019

I have an installation that has stores installed under different subdomains,
e.g.
aaa.domain.com/store/
bbb.domain.com/store/
ccc.domain.com/store/

I would like to set up the home page at www.domain.com?affiliate_id=100 to capture the affiliate cookie to pass it along to the individual stores.

In other words, I'd like a single affiliate cookie that spans all the subdomains.  Is that possible?

Is this correct?


  header('Set-Cookie: affiliate_id='. $_GET['affiliate_id'] .'; domain=domain.com; Path=/; Expires='. gmdate('r', strtotime('+6 months')));
}```
tim
Founder
Von Sweden
Mitglied seit Mai 2013
tim

Include a leading dot (.) when specifying the domain in the Domain attribute. This indicates it applies to all subdomains.
I am uncertain if "domain.com" spans all subdomains and main domain without www? It sounds reasonable that it should.

Sie
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.