I've got 2 domains - domain1.com and domain2.com - where domain1.com is my parent site and domain2.com is the child site. I'm setting cookies on domain1.com, but domain2.com needs access to those cookies.
I've researched a ton about this subject - JSONP, CORS, pick anything. EasyXDM seemed to offer a great solution. The messaging between domain2.com and domain1.com works as expected, but certain browsers, namely Chrome and IE, are not reading the cookie and therefore passing blank data.
Domain1.com has a page called status.php with the following data:
<?php
$guid = $_COOKIE['user_guid'];
?>
<!doctype html>
<html>
<head>
<title>easyXDM.Transport test</title>
<script type="text/javascript" src="/js/easyxdm/easyXDM.debug.js"></script>
</head>
<body>
<script>
var socket = new easyXDM.Socket({
onReady: function() {
socket.postMessage('<?php echo $guid; ?>');
}
});
</script>
</body>
</html>
Domain2.com has the following setup to receive the message from domain1.com:
var socket = new easyXDM.Socket({
remote: "http://domain1.com/status.php",
onMessage: function(message, origin)
{
alert("Received '" + message + "' from '" + origin + "'");
}
});
This works like a champ in FireFox, but Chrome and IE are returning an empty string, not getting the cookie data. Can anyone nudge me in the right direction with this? I can't set cookies on both domains, I just need to be able to grab the ID from the first one by any means necessary. Thanks!
As requested in the comments, here's the full code for Domain 2:
<!doctype html>
<html>
<head>
<title>Domain 2</title>
<script type="text/javascript" src="/js/easyxdm/easyXDM.debug.js"></script>
</head>
<body>
<script>
var socket = new easyXDM.Socket({
remote: "http://domain1.com/status.php",
onMessage: function(message, origin)
{
alert("Received '" + message + "' from '" + origin + "'");
}
});
</script>
<p>Hello World!</p>
</body>
</html>