/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] cookie domains

Back with a cookie question in Chrome again.

Last time I discussed this topic there was mention of possible dupe cookies which I am now seeing as a problem of sorts.

I use setcookie to set my cookies as follows:

[code]
setcookie($applid, $value, $expire, ‘/’, $domain, False, True);
[/code]

where domain is my domain name, ie, ‘domain.com’. Note it has no leading scheme nor www and definitely no extra period. YET – once set, Chrome (in the developer tools) shows me the domain as: “.domain.com”. Note the leading dot now.

I have debugged this to death and cannot figure out where that dot is coming from. Does anyone have an explanation?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 10.2017 — Ugh. Got me curious, so I read this: http://erik.io/blog/2014/03/04/definitive-guide-to-cookie-domains/

The tl;dr version seems to be that if you want to segregate your top-level domain cookies from any sub-domains, then you should explicitly set their domain to www.example.com -- which I suppose then means you'll want to set your web server config to redirect any example.com domains to www.example.com. ?

(Assuming I'm correctly understanding what I read.)
Copy linkTweet thisAlerts:
@ginerjmauthorJun 11.2017 — the only domain I use is the one (sample) that I demo'ed. No subs involved. And no www ever.

From the post you referenced, it sounds like Chrome(?) is actually adding the dot prefix although when I leave the domain value empty in my call to setcookie, it defaults the cookie to exactly what I want it to be.

Guess I have to alter my method for setting cookies to avoid any future problems with multiple cookies.
×

Success!

Help @ginerjm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...