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

J

JJA

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top