How I can set third party cookie. I am having requirement set cookie and cookie will be enable d in visited websites, Like I have set cookie in abc.com when I visit cde.com or def.com or ghi.com so set cookie will be fetch on all the website. How I can fetch cookie on all domain in javascript.
In the Privacy and Security section, select Content settings. In the Content Settings section, select Cookies. Make sure Allow sites to save and read cookie data (recommended) is toggled on. Make sure Block third-party cookies is toggled off.
Third-party cookies are created by domains that are not the website (or domain) that you are visiting. These are usually used for online-advertising purposes and placed on a website through adding scripts or tags. A third-party cookie is accessible on any website that loads the third-party server's code.
It would be possible to directly share cookies if instead of abc.com, cde.com, def.com, you would have abc.xyz.com, cde.xyz.com, def.xyz.com, (google for subdomain cookies). Maybe it is possible to set your websites like that and still meet your requirements.
Otherwise, if all of those websites cannot be in subdomains of the same domain, then you may have one of them act as a central cookie server and when the user is on other domains you could use JSONP to direct them to some script on your cookie domain that would send you their id or whatever and make your script that handles the AJAX request set its domain cookie to the same value. Example:
and now your servers can coordinate their statistics etc.
All of this is of course possible only if all of the websites cooperate with each other, ie. your websites cannot mess with cookies of other websites that you don't control as well.
UPDATE:
See also Breaking The Cross Domain Barrier talk by Alex Sexton for some inspirations and code example.
UPDATE:
If you decide to use a method similar to the one outlined above, make sure you understand the potential security issues like a possibility of a cross site request forgery attack. Search Stack Overflow for JSONP security to find more informations on how to make it safe. Keep in mind that the above explanation is a simplification of a somewhat complicated process that you need to understand. You have been warned.
You can only access your domain cookies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With