Accessing Subdomain Cookie

Discussion in 'JavaScript' started by Kristin, Sep 9, 2008.

  1. #1
    Hi,

    I have a website with

    static html pages on http://abc.com and
    dynamic php pages on http://login.abc.com

    I need to access cookie set by dynamic pages from static pages using javascript.

    What I did was to include javascriipt from http://login.abc.com into static pages. I assumed that it can access cookie from subdomain since it was loaded from subdomain. However it does not work.

    Can someone help

    Thanks
    Kristine
     
    Kristin, Sep 9, 2008 IP
  2. Kristin

    Kristin Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    can anyone help me
     
    Kristin, Sep 9, 2008 IP
  3. phongle79

    phongle79 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    when you save a variable to cookie, please add domain value. For example:
    whenever you save a variable (in both domain and subdomain) as follow:
    document.cookie = cookieName+"="cookieValue+ ";expires=" + expirationString+";path=/;domain=example.com";
    now your cookie is available in any sub-domain.
     
    phongle79, Sep 11, 2008 IP