I set cookies on other domains like this: Imagine you have two (or more) domains like:
www.mydomain.com and www.bestdomainever.com
Include one (or more) invisible GIF's hosted on the other domains. Those GIF's, however, are actually PHP scripts that set the cookie on that domain, print the mime type for a gif, and then output (readfile) the contents of an invisible GIF.
So if the user is on www.bestdomainever.com and you want to set a cookie on called "x" on www.mydomain.com and set the value to 7, include an invisible GIF like this:
<img src="http://www.mydomain.com/set-cookie-invis-gif.php?cookie=x&value=7 width=1 height=1>
Then on www.mydomain.com, you have a PHP file that:
1. sets the cookie
2. prints the mime type for a GIF
3. outputs the contents of a real invisible GIF like this:
<?php
$cookie_name = $_REQUEST['cookie'];
$cookie_value = $_REQUEST['value'];
header("Content-Type: image/x-icon");
setcookie ($cookie_name,$cookie_value);
$file = "/the/full/path/to/your/spacer.gif" ;
@readfile($file);
?>