How to allow cookie to span multiple subdomains?

Moderator
Från United States
Medlem sedan 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
Från Sweden
Medlem sedan maj 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.

Du
Denna webbplats använder inga kakor och ingen spårningsteknik från tredje part . Vi tror att vi kan göra det bättre än andra och tänker verkligen på din integritet.