How to allow cookie to span multiple subdomains?

Moderator
Van United States
Lid sinds 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
Van Sweden
Lid sinds mei 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.

U
Deze website maakt geen gebruik van cookies en geen trackingtechnologie van derden . Wij denken dat we het beter kunnen dan anderen en hechten veel waarde aan uw privacy.