Page 1 of 1
Base URL query
Posted: Mon May 30, 2005 8:50 am
by someberry
Ok, when I set a cookie, using the '/' deliminator for all subdomains etc, it only sets the cookie for
http://www.site.com, and when I access it via
http://site.com, it doesnt recognise it.
Does anyone have an idea of how to allow both access?
Thanks.
Posted: Mon May 30, 2005 9:21 am
by neophyte
From the PHP Manual
To make the cookie available on all subdomains of example.com then you'd set it to '.example.com'. The . is not required but makes it compatible with more browsers. Setting it to
http://www.example.com will make the cookie only available in the www subdomain. Refer to tail matching in the spec for details.
http://us3.php.net/setcookie
Posted: Mon May 30, 2005 2:41 pm
by someberry
Hmm, Im still having problems trying to get it to work in either
http://site.com, and
http://www.site.com - it doesnt seem to like the two, am I setting the cookie in the right way?
Code: Select all
// Prior
setcookie("c_name", "value", time()+3600, "/");
// Post
setcookie("c_name", "value", time()+3600, "/", "www.site.com");
Posted: Mon May 30, 2005 2:45 pm
by Ambush Commander
It should be:
Code: Select all
setcookie("c_name", "value", time()+3600, "/", ".site.com");