Friday, March 31, 2006

Cookies problem in ASP.NET

ASP.NET 1.1 only supports 20 user cookies

If you try to use more than that it overwrites the earlier ones with the latest ones.

so if you have:

Response.Cookies("Cookie1").Value = String
Response.Cookies("Cookie2").Value = String
Response.Cookies("Cookie20").Value = String
Response.Cookies("Cookie21").Value = String

At this stage the Cookie21 will overwrite the Cookie1

To avoid this use Cookie Keys:

Response.Cookies("Key1)("Cookie1") = String

you can do as many cookies as you like using this technique like this:

Response.Cookies("Key1)("SubKey1")("SubSubKey1")("Cookie1") = String

No comments: