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.

Re: How does Response.Cookies really work with keys? by Ray

Ray
Tue Apr 13 10:05:20 CDT 2004

Concatenate the values?

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

Ray at work


"JJA" <johna@cbmiweb.com> wrote in message
news:2cfb40c2.0404130648.5b635668@posting.google.com...
> 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.



Re: How does Response.Cookies really work with keys? by Dave

Dave
Tue Apr 13 13:26:18 CDT 2004

JJA wrote:
>
> 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.



Re: How does Response.Cookies really work with keys? by johna

johna
Thu Apr 15 12:45:49 CDT 2004

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.