Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Cookie with subkeys


Message #1 by nicoaumar@t... on Thu, 27 Feb 2003 16:00:23
In the "old" ASP I use to do:

Response.Cookies("key")("lastVisit") = Now
Response.Cookies("key").Expires = DateAdd("YYYY", 1, Now)

And the cookie ("key")("IP") in the client was not affected by that.

But now with C# I do:
Response.Cookies["key"]["lastVisit"] = DateTime.Now;
Response.Cookies["key"].Expires = DateTime.Now.AddYears(1);

and the cookie ["key"]["IP"] in the client gets deleted!

Does anyone know anything about this?
Thanks

Nick

Message #2 by "Mark [Demontools.net]" <mark@d...> on Thu, 27 Feb 2003 16:00:00 -0000
I think what's happening now is actually correct. This is from memory so I
hope it's accurate, but if you set any of the sub-keys of a cookie, you have
to re-set them all. Nothing to do with ASP or ASP.NET but simply the way
it's meant to work.

If you have five sub-keys in a cookie previously set, and you want to change
just one, you have to rewrite all five back out again. You can't just change
one of them - it's all or nothing.

So the top section of your code (for ASP) should have deleted the ID sub-key
as well. I think ;)

Mark

-----Original Message-----
From: nicoaumar@t... [mailto:nicoaumar@t...]
Sent: 27 February 2003 16:00
To: ASP.NET
Subject: [aspx] Cookie with subkeys


In the "old" ASP I use to do:

Response.Cookies("key")("lastVisit") = Now
Response.Cookies("key").Expires = DateAdd("YYYY", 1, Now)

And the cookie ("key")("IP") in the client was not affected by that.

But now with C# I do:
Response.Cookies["key"]["lastVisit"] = DateTime.Now;
Response.Cookies["key"].Expires = DateTime.Now.AddYears(1);

and the cookie ["key"]["IP"] in the client gets deleted!

Does anyone know anything about this?
Thanks

Nick





  Return to Index