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?