SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Read Cookie by Domain Names

    can any one help to find how to read cookies using javascript by its domain name?

    for ex: if cookie is set by www.examplesite.com on my browser and i am working on www.mysite.com where i want to read cookie set by www.examplesite.com.

    Please Note : i am not sure by which method the cookie is getting write on my machine, it may be php, asp or anything but i want to read perticulaer cookie values ....

    i dont understand if cookie is set on my machine then why i am not able to read it.

    i hope this explanation if helpful.....
    please help me to find this using javascript .

    In advance thank you very much.
    Last edited by simplecode; Jul 27, 2007 at 04:34.

  2. #2
    SitePoint Addict jtrelfa's Avatar
    Join Date
    Oct 2004
    Location
    Troy, Mi
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You cannot read cookies from another domain - it's a security issue and all browsers prevent it. You can only read/write cookies for the domain you're on.

    Here's (part of) the specification:
    The following rules apply to choosing applicable cookie-values from
    among all the cookies the user agent has.

    Domain Selection
    The origin server's fully-qualified host name must domain-match
    the Domain attribute of the cookie.

    Path Selection
    The Path attribute of the cookie must match a prefix of the
    request-URI.
    The RFC can be found here:
    http://www.w3.org/Protocols/rfc2109/rfc2109
    var me = null;

  3. #3
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but the cookie is set on my machine then why i cant read this ? could you please help me ...

    thanks for reply

  4. #4
    SitePoint Addict jtrelfa's Avatar
    Join Date
    Oct 2004
    Location
    Troy, Mi
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It has nothing to do with the physical machine - it has to do with the domain.
    var me = null;

  5. #5
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much for your help .


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •