- When you read Response.Cookies[somename], the cookie is automatically created and returned if it does not already exist. Code which checks if(Response.Cookies[somename] == null) is pointless.
(This does not apply to Request.Cookies) - When a cookie is added to Response.Cookies, it is automatically added to Request.Cookies too. Ditto for deletes.
- Want more? If you add a cookie to Response.Cookies and it already exists in Request.Cookies, then Request.Cookies will have two cookies with the same name. So it is better to do a Request.Cookies.Remove(somename) before Response.Cookies[somename].
For cookies using multiple values it makes sense to reuse the cookie which was removed from Request.Cookies. - If you'd like even more bugs with your ASP.NET: Response.Cookies Bug
Thursday, March 16, 2006
Cookies in ASP.NET
Cookie collections in ASP.NET are just weird to say the least. I'm too tired to go into details. Just remember this:
Subscribe to:
Post Comments (Atom)
About Me
- Agnel CJ Kurian
- C/C++ Programmer doing CAD on Windows. Some web development experience. Bangalorean.
Blog Archive
Labels
- .net (11)
- advocacy (1)
- apache (2)
- code (1)
- direct3d (1)
- drawing (1)
- geometry (1)
- graphics (1)
- humour (1)
- javascript (1)
- links (1)
- microsoft (1)
- morons (1)
- postgresql (1)
- programming (4)
- python (1)
- rant (5)
- software (1)
- subversion (2)
- svn (1)
- tools (11)
- trac (1)
- truecrypt (1)
- typing (1)
- vc++ (14)
- video (1)
- vs2008 (1)
- windows-forms (1)
- windows7 (1)
1 comment:
Cookies, like session are created when u assign a value to the cookies. You may have to check
if(Request.Cookies!=null) when u are accessing the cookie value.
Post a Comment