setCookie: Cross-Domain Cookie write


Nothing more simple as:
1) create domain1.com/client.html with source:
<script type=”text/javascript” src=”domain2.com/server_set_cookie.php”></script>
2) create domain2.com/server_set_cookie.php with php source:

header(“p3p: CP=ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV”);

setcookie(‘cookie_name’, ‘cookie_value’, time()+3600);

You are done! By visiting domain1.com/client.html you will create cookie for yourself at domain2.com!

About these ads

4 responses to “setCookie: Cross-Domain Cookie write

  1. I am a PHP developer. I am working on wordpress site. I need to create cookies on multi-domain. I try to use your code. It’s working on firefox but not other brower . please help me

  2. Hi,
    Did you execute the code inside a WordPress site? If yes, first try to execute it separately, as is.
    And re-check you don’t miss a line of code.

  3. Sure enough, I fixed the code. Sorry for confusion and thanks for pointing on it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s