467,087 Members | 1,242 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,087 developers. It's quick & easy.

Reading Cookie from a different domain?

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*
Jul 20 '05 #1
  • viewed: 43478
Share:
3 Replies
Hi,

kam bansal wrote:
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
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #2
I could swear that there is a way to do this. You can share cookies with
your other sites in some way (seems to me it involved using IP addresses
instead of domains.) Not really recommended though.

"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:3f**********@news.bluewin.ch...
| Hi,
|
| kam bansal wrote:
| > 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
| --
| Laurent Bugnion, GalaSoft
| Webdesign, Java, javascript: http://www.galasoft-LB.ch
| Private/Malaysia: http://mypage.bluewin.ch/lbugnion
| Support children in Calcutta: http://www.calcutta-espoir.ch
|
Jul 20 '05 #3
kam bansal <ka*@magickhat.com> writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by milindsj@gmail.com | last post: by
1 post views Thread by Reinhold Mannsberger | last post: by
9 posts views Thread by Mike Reed | last post: by
2 posts views Thread by Sean | last post: by
2 posts views Thread by Cathy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.