can I add a new name-pair to an existing cookie?

K

Kevin Blount

I have an issue with trying to add a new name-pair to an existing
cookie. Here's what I want to do:

page1 -
adds "loggedin=true" to cookie "Communities"
adds "member_id=100" to cookie "Communities"

page2 -
adds "banner=1" to cookie "Communities"

page 3 -
reads cookie "Communities"

first I would run page 1, then page 2 and finally page 3

in original ASP if I did this page would show something like:
cookie name: "Communities"
cookie value: "loggedin=true&member_id&100&banner=1"

but in my ASP.NET (C#) scripts, page 3 shows:
cookie name: "Communities"
cookie value: "banner=1"

it seems page 2 overwrites the cookie. Is there any way to add the
name-pair from page 2 without overwriting those from page 1?

If necessary I will stop using collections and just make multiple
cookies with a common prefix (such as commLoggedIn, commBanner, etc),
but I'd really like to keep collections, and in my current ASP code
(which is being updated to .NET) I have multiple collections.

I guess I could try and write a function that is passed a new or
existing name-value pair; reads the current value of the collection and
adds each one back individually either updating one or adding a new
one, but that seems too much effort.

any help appreciated
 
K

Kevin Blount

Thanks for the reply.

I figured, after hours of research, that would be the case. Seems a
chame that in this case ASP.NET is a step back from original ASP, but
maybe I'm missing something as to why is had to be done this way.

cheers

Kevin
 

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

Top