How does Response.Cookies really work with keys?

J

JJA

I think I made the original subject line too weird or something. I
believe I now see how this works but I was hoping someone could offer
a neat workaround. Is there some property I could add to make
Response.Cookies merge data into a Javascript written cookie (with
keys) rather than overwrite it? Thanks in advance for trying to help
on this.
 
R

Ray at

Concatenate the values?

<% Response.Cookies("JJAsCookie") = Request.Cookies("JJAsCookie") & " some
additional data." %>

Ray at work
 
D

Dave Anderson

JJA said:
Is there some property I could add to make Response.Cookies
merge data into a Javascript written cookie (with keys)
rather than overwrite it?

I don't understand the question. Are you asking whether you can add to the
Request.Cookies collection? (Answer: no, though I suppose it *might* be
useful in conjuction with Server.Transfer...)

The cookie values can obviously be merged with any other values you like.
But if you want to store those merged values in a cookie on the client, you
have two options: put the values in the Response.Cookies collection or use
client-side scripting to do it.

As for merging -vs- overwriting, who cares how the client deals with the
cookie?


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
J

JJA

Here is the original question posted April 9 (I got no response so I
posed the question briefly again with a different subject)...

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

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top