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.
Base URL query
Moderator: General Moderators
From the PHP Manual
http://us3.php.net/setcookieTo 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.
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");- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
It should be:
Code: Select all
setcookie("c_name", "value", time()+3600, "/", ".site.com");