How to create a cookie with an external domain?

I created a javascriptscript that people can upload to their websites asynchronously by pasting a little code like Facebook, Google, when we want to integrate the SDK javascript. From my script, I want to create a cookie with my domain as Facebook, Google does with their domain. I am trying to create a cookie with a domain using the small frame set by Mozilla .

docCookies.setItem('cookie1', 'some value',Infinity, '/', '.example.com');

Where ".example.com" is my domain name, where I have this script that people upload to their site. I am trying to create this cookie in any domain that my script loads. But it does not work, cookie has not been set yet. How can I create a cookie with my domain from this script to another domain?

[Sorry for my bad English.]

+4
source share
1 answer

This could be an explanation:

If you understand correctly, your script is downloaded from the site www.example.com, but used by sites in other domains, say, www.someotherdomain.com.

If you create a cookie and try to use this cookie in a request from www.someotherdomain.com to www.example.com, the browser will consider it a third-party cookie. Cookies are a third-party cookie because the domain you are located on (www.someotherdomain.com) is different from the domain to which the request is sent (www.example.com).

Several browsers block third-party cookies, so cookies are not included in the request for www.example.com.

, cookie, .

+2

All Articles