Can Response.Cookie("X")("KEY1") leave existing keys intact?

Discussion in 'ASP General' started by JJA, Apr 9, 2004.

  1. JJA

    JJA Guest

    I am using a single cookie with up to around 20 or so KEY/VALUE pairs.
    I have an existing cookie built up through user interaction on the
    client side where events lead to writing out an associative array with
    Javascript via document.cookie. Then when the form is submitted, the
    page that is posted takes data out of the form and writes the cookie
    again (snippet follows):

    strCrumb = Request.form("ddState")
    if len(strCrumb) > 0 then
    Response.Cookies("MDW")("STATE") = strCrumb
    end if
    strCrumb = Request.form("ddCounty")
    if len(strCrumb) > 0 then
    Response.Cookies("MDW")("COUNTY") = strCrumb
    end if
    strCrumb = Request.form("ddMetro")
    if len(strCrumb) > 0 then
    Response.Cookies("MDW")("METRO") = strCrumb
    end if
    '... etc. (more of the same testing of form elements, setting of
    cookie keys)

    Response.Cookies("MDW").Expires = DateAdd("d", 180, Now)
    Response.Cookies("MDW").Path = "/"
    Response.Cookies("MDW").Domain = "www.mortgagedataweb.com"

    A typical Response.Cookies above "adds" or "replaces" a given
    key:value pair but I am noticing that it does not preserve any prior
    key:value pairs. In other words, any prior cookie key:value pair
    written by Javascript is lost if not in the above form.

    Is there a way to make the above example preserve an existing value
    for say, METRO, if the form only contains ddState and ddCounty?
    Ideally, I'd like the above code fragment to "merge" any matching
    values in the response.cookies
    collection leaving anything "unmatched" alone and preserved. Thanks.
     
    JJA, Apr 9, 2004
    #1
    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. ad
    Replies:
    2
    Views:
    7,527
    Kevin Spencer
    Jan 27, 2006
  2. exquisitus
    Replies:
    6
    Views:
    564
    exquisitus
    May 4, 2005
  3. Keith
    Replies:
    2
    Views:
    118
    Mark Schupp
    Oct 23, 2003
  4. bradjpeek
    Replies:
    4
    Views:
    109
    Curt Hibbs
    Aug 3, 2006
  5. Mike
    Replies:
    1
    Views:
    149
    kaeli
    Sep 8, 2004
Loading...

Share This Page