You could directly share cookies if, instead of abc.com, cde.com, def.com, you have to abc.xyz.com, cde.xyz.com, def.xyz.com, (google for cookies subdomains ). Perhaps you can customize your sites this way and still meet your requirements.
Otherwise, if all these websites cannot be in subdomains of the same domain, then you can use one of them as a central cookie server, and when the user is in other domains, you can use JSONP to direct them to some script in your cookie domain, which will send you its identifier or something else, and make your script that processes the AJAX request, set its domain cookie to the same value. Example:
- user visits def.com
- JavaScript code on def.com makes JSONP request on abc.com
- abc.com sets a cookie if not already set
- abc.com returns cookie as response to script on def.com
- script on def.com sets its local cookie def.com with the same value
and now your servers can coordinate their statistics, etc.
All this, of course, is possible only if all the websites cooperate with each other, i.e. your websites cannot interact with cookies from other websites that you also do not control.
UPDATE:
See also Alex Sexton Cross-Barrier Talk for some inspiration and code examples.
UPDATE:
If you decide to use a method similar to that described above, make sure that you understand the potential security problems as the possibility of faking a request to use the site . Search for JSONP security to find additional information on how to make it safe. Keep in mind that the above explanation is a simplification of a complex process that you need to understand. You have been warned.
source share