Reading Cookie from a different domain?

L

Laurent Bugnion, GalaSoft

Hi,

kam said:
Hi all,

Can javascript read a cookie from a different domain? Meaning, if my
html page is running on "www.mydomain.com" and I goto another domain
"www.another.com" to do some work, and then I come back, can I see the
cookie that "www.another.com" created from my domain???

Any thoughts?

~Kam (^8*

No, that would be a big security breach.

The only thing you can do to transmit information between
www.another.com and www.mydomain.com is call the URL with parameters,
for example:

www.mydomain.com?param1=value1&param2=value2

Laurent
 
L

Lasse Reichstein Nielsen

kam bansal said:
Can javascript read a cookie from a different domain? Meaning, if my
html page is running on "www.mydomain.com" and I goto another domain
"www.another.com" to do some work, and then I come back, can I see the
cookie that "www.another.com" created from my domain???

That depends on security settings.
If you have "disallow third party cookies", then it won't work. Then
"www.another.com" cannot set cookies for other domains than itself.

If not, you can set the cookies with a domain of "mydomain.com".
IIRC:
document.cookie = "dims=data;domain=www.mydomain.com;path=/;expires=..."

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top