I have created a javascript
script which people can asynchronously load to their websites by pasting a small code like Facebook, Google does when we want to integrate their javascript
SDK. From my script I want to create a cookie with my domain as Facebook , Google does with their domain. I'm trying to create cookie with domain by that little framework given by Mozilla.
docCookies.setItem('cookie1', 'some value',Infinity, '/', '.example.com');
Where '.example.com' is my domain name where I have that script which people loading to their website. I'm trying to create that cookie in any domain which load my script. But it's not working, no cookies have been set so far. How I can create a cookie with my domain from that script to other domain?
[Sorry for my bad English.]
This might be the explanation:
If I understand you correctly, your script is loaded from www.example.com, but used by sites on other domains, let's 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 this a third-party cookie. The cookie is a third-party cookie becuase the domain you're at (www.someotherdomain.com) differs from the domain the request is sent to (www.example.com).
Several browsers block third-party cookies, and the cookie is therefore not included in the request to www.example.com.
There's no way you can stop the browsers blocking third-party cookies, you'll have to look at alternative techniques.
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