PHP: Cookie domain / subdomain control

PHP’s cookie functions automatically prefix the $domain with a dot. If you don’t want this behavior you could use the header function. For example:

header("Set-Cookie: cookiename=cookievalue; expires=Tue, 06-Jan-2009 23:39:49 GMT; path=/; domain=subdomain.example.net");

Leave a Comment