Cookies in ASP.NET

DayWalkers

New Member
I'm trying to store key-value pairs in a cookie. There might be a better way, I'm not sure. Basically, I've got a username and an id. Here's the code to initially load the cookie (that works fine):<BR><BR>while( dataReader.Read() )<BR>{<BR>&nbsp;&nbsp;Response.Cookies[ "Teams" ].Values.Add( dataReader.GetString( 0 ), dataReader.GetInt16( 1 ).ToString() );<BR>}<BR>dataReader.Close();<BR><BR>My trace output for this cookie then looks like this:<BR>Name Value<BR>----- -----------------------<BR>Teams (Cardington=8) (CWRU=6)<BR><BR>If, on another page, I try adding another team to this using the following line of code (which appears to me to be equivalent to the code from before):<BR><BR>Response.Cookies[ "Teams" ].Values.Add( txtTeamName.Text, prams[ 3 ].Value.ToString() );<BR><BR>I get the following trace output:<BR><BR>Name Value<BR>----- -----------------------<BR>Teams (Cardinals=34)<BR><BR>I think that I am completely overwriting the cookie, which isn't what I want to do. I just want to add a value to the cookie. Can anyone help me out? This minor issue is really slowing down development and time is limited.<BR><BR>Thanks,<BR> Branton
 
Back
Top