Setting cookies for other domains

From: Date: Fri, 18 Mar 2005 00:44:35 +0000
Subject: Setting cookies for other domains
Groups: php.general 
Request: Send a blank email to php-general+get-211003@lists.php.net to get a copy of this message
I've always known that you can specify a domain when you set a cookie, and for kicks I experimented with a test page setting a cookie for the yahoo.com. Seems to me that browsers wouldn't allow this as it could create any number of security problems. I tried the following code, and the yahoo cookie did not get set, as I expected, and the briandunning.com cookie did (that's my site). I made sure that my browser's settings were set to allow all cookies, including those from other sites. <?php setcookie('test', 'anything', time()+31536000, '/', '.yahoo.com'); setcookie('test', 'anything', time()+31536000, '/', '.briandunning.com'); ?> Question: why didn't this work, is it supposed to work the way I was trying, and if not, then what is that domain variable there for??? - Brian

« previous php.general (#211003) next »