Web Hosting Talk







View Full Version : setcookie() troubles on different subdomains, need help


waturl
06-01-2009, 04:47 AM
Hello,

how can i set a cookie on different subdomains ?

Kohrar
06-01-2009, 05:14 AM
I would do something like this:


setcookie("key", "value1", 0, "/", "subdomain1.server.com");
setcookie("key", "value2", 0, "/", "subdomain2.server.com");


change the expire time name and value of the cookies accordingly.

JoyceBabu
06-01-2009, 06:05 AM
To set separate cookie for separate subdomains use Kohrar's code. If you want same cookie accessible from multiple subdomains use
setcookie('key', 'value', 0, '/', '.domain.com');

waturl
06-01-2009, 10:58 AM
I have about 7 subdomains, well i'm going to try

setcookie('key', 'value', 0, '/', '.domain.com');