Forum Moderators: open

Message Too Old, No Replies

Problems with images setting cookies in a different domain

foo1.com loads an image from foo2.com

         

guarriman

6:28 pm on Nov 6, 2007 (gmt 0)

10+ Year Member



Hi.

I want to set two cookies to user's web-browser in foo2.com but when user visits foo1.com. Very similiar to the system used by web statistics.

I use (within 'http://www.foo1.com/page.html'):
------
<img src="http://www.foo2.com/image.php" />
------

And 'www.foo2.com/image.php' sets the two cookies.

It works ok on Firefox on Linux, but doesn't work with Firefox on MS Windows and IExplorer. Any similar experience? Thank you very much.

rocknbil

11:18 pm on Nov 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I'm getting you right, what you're asking *should* be impossible. If someone could read cookies set by other domains they could use that information for nefarious means.

A cookie should only be able to be read from the domain it's set on. However, what you *can* do, using PHP, is send a value via query string to set a new cookie on domain2:

domain 1
set-cookie:my_cookie=my_value123;path=/;

[example_domain2.com...]

domain 2:
set=cookie:my_cookie=$_POST["c"];path=/;