Problems setting a cookie that already exists
- From: Alan Silver <alan-silver@xxxxxxxxxxxx>
- Date: Thu, 29 Sep 2005 18:31:05 +0100
Hello,
I have discovered that if I try and add a cookie when one by that already exists, nothing happens. No error, but the cookie is not set to the new value.
For example (this is running in a DLL, which is why I use HttpContext)...
HttpCookie cookie = new HttpCookie("fred", "ferret");
DateTime expiryDate = DateTime.Now.AddMonths(1);
cookie.Expires = expiryDate;
HttpContext.Current.Response.Cookies.Add(cookie);works fine if the cookie "fred" does not already exist, but if it does, then it is not updated to have the new value.
How do I handle this? I tried...
HttpContext.Current.Response.Cookies["fred"] = cookie;
but that didn't do anything either. Either way, the old value remains in the cookie.
Any advice appreciated.
-- Alan Silver (anything added below this line is nothing to do with me) .
- Follow-Ups:
- Re: Problems setting a cookie that already exists
- From: Alan Silver
- Re: Problems setting a cookie that already exists
- Prev by Date: Re: How to share VB code across multiple pages?
- Next by Date: Re: IStateManager in a class object
- Previous by thread: DataView.RowFilter problem
- Next by thread: Re: Problems setting a cookie that already exists
- Index(es):
Relevant Pages
|