473,385 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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

Jul 20 '06 #1
2 2414
you'd need to first extract the value of the cookie and append to it then
store it back.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
"Kevin Blount" <ke**********@gmail.comwrote in message
news:11*********************@m79g2000cwm.googlegro ups.com...
>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

Jul 21 '06 #2
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

Alvin Bruney [MVP] wrote:
you'd need to first extract the value of the cookie and append to it then
store it back.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
Jul 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: stewart.midwinter | last post by:
No doubt I've overlooked something obvious, but here goes: Let's say I assign a value to a var, e.g.: myPlace = 'right here' myTime = 'right now' Now let's say I want to print out the two...
2
by: Ravi | last post by:
My XML looks like: <abc> <def type="apple"> 1 </def> <def type="peach"> 2 </def> <def type="orange"> 3 </def> <def type="banana"> 4 </def> <def type="plum"> 5 </def> </abc>
1
by: discomiller | last post by:
Mario Mueller: Hello *, radiobuttons belong to other radiobuttons by the "name="any_value"" attribut. Thats a fakt. I got the following XML:...
21
by: TheKeith | last post by:
I heard that the name attribute is deprecated in html 4.01 strict. Is it recommended that you use the ID attribute for images along with the getElementById method instead of the old way? Thanks.
12
by: CJ | last post by:
Why won't this work? I am passing the name of the form (I have two that use this validation script) but I keep getting an error. Error reads: "document.which_form.name is null or not an object" ...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
3
by: jparulan | last post by:
Hi All, I'm using SOAP3.0. I was able to successfully call a WSDL file and get a value properly. But when the WSDL changed to have a MULTIPLE <element name> it was failing. This code works...
1
by: ivanet | last post by:
Hello everyone, I am trying to use the following Schema but I get the error "src- resolve: Cannot resolve the name 'ValuesList' to a(n) 'element declaration' component." at line 144. I have...
2
by: pythonnewb | last post by:
I am fairly new to programming but have some very basic Java background. I am just learning python and tried to make a module that would allow me to create a file containing an address book. I was...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.