1

I have two domains:
login.com and site.com

On the page login.com/ajax.htm I have the following code:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script>
$(function() {
   $.get('http://site.com/setCookie.php', {}, function(text) {alert(text);});
});
</script>

setCookies.php on site.com contains only:

header('Access-Control-Allow-Origin: *');
setcookie('Cookie', 'Cookie', time()+60*60*24*30, '/', 'example.com');
setcookie('Cookie3', 'Cookie3', time()+60*60*24*30, '/', '.example.com');
setcookie('Cookie4', 'Cookie4', time()+60*60*24*30, '/', '');
setcookie('Cookie5', 'Cookie5');
echo 'Cookies set';

All I want is that setCookies.php will set cookies for site.com, when requested from ajax.htm.

Actually, when I visit login.com/ajax.htm, I get JS alert "Cookies set", but none of them are set, in fact :)

So the question is, how I can make a script set cookie for its own domain (not for the domain from which its being requested), when it is requested with AJAX?

7audio
  • 19
  • 2
  • depending on what you want, you could use an iframe simply to make communications possible, see http://stackoverflow.com/questions/1949764/cross-domain-iframe-communication – Nick Andriopoulos May 20 '13 at 13:03
  • @hexblot Thank you, but I actually already implemented same functionality with ` – 7audio May 20 '13 at 13:07

0 Answers0