Reading Cookie from a different domain?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kam bansal

    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.c om" and I goto another domain
    "www.another.co m" to do some work, and then I come back, can I see the
    cookie that "www.another.co m" created from my domain???

    Any thoughts?

    ~Kam (^8*
  • Laurent Bugnion, GalaSoft

    #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.c om" and I goto another domain
    > "www.another.co m" to do some work, and then I come back, can I see the
    > cookie that "www.another.co m" 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

    Comment

    • Nobody

      #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_S PAM.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.c om" and I goto another domain
      | > "www.another.co m" to do some work, and then I come back, can I see the
      | > cookie that "www.another.co m" 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
      |


      Comment

      • Lasse Reichstein Nielsen

        #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.c om" and I goto another domain
        > "www.another.co m" to do some work, and then I come back, can I see the
        > cookie that "www.another.co m" 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.co m" cannot set cookies for other domains than itself.

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

        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        Working...