Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Reading Cookie from a different domain?

Question posted by: kam bansal (Guest) on July 20th, 2005 10:01 AM
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*
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Laurent Bugnion, GalaSoft's Avatar
Laurent Bugnion, GalaSoft
Guest
n/a Posts
July 20th, 2005
10:01 AM
#2

Re: Reading Cookie from a different domain?
Hi,

kam bansal wrote:[color=blue]
> 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*[/color]

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


Nobody's Avatar
Nobody
Guest
n/a Posts
July 20th, 2005
10:01 AM
#3

Re: Reading Cookie from a different domain?
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:3f57664a$1_2@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
|



Lasse Reichstein Nielsen's Avatar
Lasse Reichstein Nielsen
Guest
n/a Posts
July 20th, 2005
10:02 AM
#4

Re: Reading Cookie from a different domain?
kam bansal <kam@magickhat.com> writes:
[color=blue]
> 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???[/color]

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 - Join Bytes!
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'

 
Not the answer you were looking for? Post your question . . .
184,039 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors