A
Alan Silver
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.
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.