Query on retrieving cookies through javascript

Discussion in 'Javascript' started by vipul, Mar 26, 2008.

  1. vipul

    vipul Guest

    Hi,

    Is there any way by which we can retrieve those cookies through
    javascript which have path set to other than root "/".

    When I try to fetch the cookies with the help of document.cookie, only
    those cookies are being retrieved which have path set as root.

    Regards,
    Vipul
     
    vipul, Mar 26, 2008
    #1
    1. Advertising

  2. vipul wrote:

    > Is there any way by which we can retrieve those cookies through
    > javascript which have path set to other than root "/".
    >
    > When I try to fetch the cookies with the help of document.cookie, only
    > those cookies are being retrieved which have path set as root.


    It depends on the URI that reads out the cookies. For instance, if a
    cookie was set with a path '/html', then document.cookie returns the
    cookie only if the caller page resides in directory '/html' on the
    server. Paginae outside of '/html' cannot read that cookie, since it's
    only accessible from '/html'.

    '/' as default root path means that any cookie from a domain can be
    read by any page from that same domain. If you set a path like '/html/
    mypage.htm', then the cookie can only be accessed from that page.

    Hope this helps,

    --
    Bart
     
    Bart Van der Donck, Mar 26, 2008
    #2
    1. Advertising

  3. vipul

    vipul Guest

    On Mar 26, 2:40 pm, Bart Van der Donck <> wrote:
    > vipul wrote:
    > > Is there any way by which we can retrieve those cookies through
    > > javascript which have path set to other than root "/".

    >
    > > When I try to fetch the cookies with the help of document.cookie, only
    > > those cookies are being retrieved which have path set as root.

    >
    > It depends on the URI that reads out the cookies. For instance, if a
    > cookie was set with a path '/html', then document.cookie returns the
    > cookie only if the caller page resides in directory '/html' on the
    > server. Paginae outside of '/html' cannot read that cookie, since it's
    > only accessible from '/html'.
    >
    > '/' as default root path means that any cookie from a domain can be
    > read by any page from that same domain. If you set a path like '/html/
    > mypage.htm', then the cookie can only be accessed from that page.
    >
    > Hope this helps,
    >
    > --
    >  Bart


    Hi Bart,

    Thanks for replying.
    The issue is that I can not change the location of the form. I am
    still struggling with the issue :(

    Thanks,
    Vipul
     
    vipul, Mar 28, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Nitulescu

    Response.Cookies vs Request.Cookies

    Alex Nitulescu, Feb 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    8,516
    Hans Kesting
    Feb 3, 2005
  2. _Who
    Replies:
    7
    Views:
    2,699
  3. Vikram Bhatia
    Replies:
    1
    Views:
    238
    kaeli
    Oct 11, 2003
  4. Peter v.d. Berger

    Retrieving cookies from a webserver

    Peter v.d. Berger, Sep 26, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    75
    A. Sinan Unur
    Sep 27, 2004
  5. asg

    Retrieving Cookies

    asg, May 15, 2006, in forum: Javascript
    Replies:
    1
    Views:
    70
    David Dorward
    May 15, 2006
Loading...

Share This Page