PC Review


Reply
Thread Tools Rate Thread

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

 
 
Kevin Blount
Guest
Posts: n/a
 
      20th Jul 2006
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

 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      21st Jul 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
>



 
Reply With Quote
 
Kevin Blount
Guest
Posts: n/a
 
      21st Jul 2006
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
> -------------------------------------------------------


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Starting SyncToy from command line and pass new/existing folder pair ? Werner Kraus Windows XP Help 1 1st Nov 2006 10:58 PM
Starting SyncToy from command line and pass new/existing folder pair ? Werner Kraus Windows XP Photos 1 1st Nov 2006 10:58 PM
Changing an existing Synctoy pair? =?Utf-8?B?WGhpcw==?= Windows XP Photos 0 31st Oct 2006 10:49 PM
Changing an existing Synctoy pair? =?Utf-8?B?TGlvbmVs?= Windows XP Photos 0 24th Aug 2006 06:42 PM
using an existing cookie with WebRequest Microsoft Dot NET 0 26th Nov 2003 02:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:11 PM.