Reputation: 481
I have a page on domainA.com
which calls a script <script src="https://domainB.com/script.js"></script>
can I set from script.js
in javascript a cookie on domainB?
Or I can only do it server-side with http header?
I tried with document.cookie = '..; domain=domainB.com;...';
but it nothing happens
Upvotes: 2
Views: 156
Reputation: 944296
JavaScript always executes in the context of the HTML document it is running inside.
can I set from script.js in javascript a cookie on domainB?
Not with client-side JS.
Or I can only do it server-side with http header?
Yes. This could be set in the HTTP response to the request for script.js
.
Upvotes: 2