Can you read a cookie set via javascript?

Discussion in 'ASP .Net' started by Darrel, Dec 28, 2008.

  1. Darrel

    Darrel Guest

    I'm working on a site where the cookie is set via javascript.

    I'm trying to now read it via vb.net

    It appears that one can't do this. Is that true?

    -Darrel
     
    Darrel, Dec 28, 2008
    #1
    1. Advertising

  2. Darrel

    Darrel Guest

    > I'm working on a site where the cookie is set via javascript.
    >
    > I'm trying to now read it via vb.net
    >
    > It appears that one can't do this. Is that true?


    Ah! I figured out waht was going on. I can read cookies that were set in the
    same directory as my aspx page.

    So if the cookie is set at the root '/', then my aspx page that is in the
    root can read it. However if the cookie was set on a page in a subdirectory
    such as '/subdirectory/' then I can't read it from my ASPX page.

    It looks like this is an issue of javascript and how I'm setting it. It
    appears the cookie is directory-centric.

    off to explore...

    -Darrel
     
    Darrel, Dec 28, 2008
    #2
    1. Advertising

  3. Darrel

    Darrel Guest

    > It looks like this is an issue of javascript and how I'm setting it. It
    > appears the cookie is directory-centric.


    Well, it appears I can set a directory for the cookie in both javascript and
    asp.net by adding a 'path=/' property to the cookie.

    If I then delete all cookies to remove the previous ones set per directory,
    I can then grab the cookie via asp.net

    Cool!

    -Darrel
     
    Darrel, Dec 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. Josh T
    Replies:
    2
    Views:
    656
    Alexey Smirnov
    Jun 9, 2007
  2. Replies:
    5
    Views:
    577
    Aaron Watters
    May 2, 2008
  3. Replies:
    2
    Views:
    472
  4. Phil Powell
    Replies:
    2
    Views:
    191
    Grant Wagner
    Sep 5, 2003
  5. emilgo

    Read cookie with different cookie

    emilgo, Feb 13, 2004, in forum: Javascript
    Replies:
    0
    Views:
    93
    emilgo
    Feb 13, 2004
Loading...

Share This Page