[thelist] Cookie / Count problems (fwd)

Keith cache at dowebs.com
Mon Dec 10 13:02:29 CST 2001


 Hi Daniel

> subdomains (so when the cookie was placed on auto.start.be it should
> be retrieved on microsoft.start.be, www.start.be and even start.be) 

You have to tell the browser which hosts are allowed to read the 
cookie, www, auto, and microsoft are separate hosts for the 
domain start.be. This is done in the cookie set string with 
"domain=www.start.be" if you want www to be the only host for 
start.be to have access. If you want all hosts for start.be to have 
access you would use "domain=.start.be" Notice that there are two 
periods in that string. The specs require two or more periods in the 
value if the domain attribute is set.

I'm looking at NN3 specs for cookies. It states that two or more 
periods must be in the value if the TLD is one of "COM", "EDU", 
"NET", "ORG", "GOV", "MIL", or "INT" but must have three periods 
for other TDLs. Your TDL "be" may therefore need three periods. I 
assume later (global-friendly) browsers opened that two period rule 
to other TDLs. But I don't have access to a non-USA-centric TDL so 
I can't test it. You may need to experiment.

To set the domain attribute use something like:

$domain=".start.be";
print "Set-Cookie: counter_id=$time;domain=$domain;path=/\n";

That should allow access to any path in all your start.be domains if 
the two period rule extends to "be".

Other thought: I think you're overthinking your problem. You're 
keeping track of the browser's visits by keeping a log for that 
browser in MySQL based on the browser's cookie id. By your 
description all you want is a correct aggregate unique visitor count, 
not a log of each unique visitor's number of visits. If that's all you 
want, then all you have to do is tag the browser as having already 
been counted and then not count any browsers if the tag is found. 
Set a cookie something like "been_counted=1" and then don't 
increment your aggregate unique visitor count if a cookie named 
"been_counted" is found. 

Let us all know how the two period rule works for "be".

keith




More information about the thelist mailing list