Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Settings cookie cross domain

5 views
Skip to first unread message

Willi Langer

unread,
Jul 16, 2012, 10:48:40 AM7/16/12
to
Hi all,
I have a few questions:

1- in a web page, if I include a javascript hosted on a remote server,
can it set a cookie in my domain?

i.e.
WWW.MYSITE.COM
<script src="http://www.externalsite.com/my.js">….

Can it set a cookie having domain mysite.com?

2. can a javascript set a cookie in a domain different of the one who
hosted it?

Thanks in advance and sorry for my english.
W.

Thomas 'PointedEars' Lahn

unread,
Jul 16, 2012, 5:28:18 PM7/16/12
to
Willi Langer wrote:

> 1- in a web page, if I include a javascript hosted on a remote server,
> can it set a cookie in my domain?
>
> i.e.
> WWW.MYSITE.COM
> <script src="http://www.externalsite.com/my.js">….

The proper TLD for examples is `example', not `com', because a `com' domain
might be used. See RFC 2606.

> Can it set a cookie having domain mysite.com?

Yes. Just try it (in many browsers) and you will see.

> 2. can a javascript set a cookie in a domain different of the one who
> hosted it?

Yes, if the other domain belongs to the same sub-level domain.

> Thanks in advance and sorry for my english.

There is also a German-speaking newsgroup on this subject,
de.comp.lang.javascript, where your questions will be as welcome. See also
<http://dcljs.de/>.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
0 new messages