ASP.NET: Cookies, value not being reset, cookie not being removed -
i have cookie called "g" values "y" or "n"
i set this:
response.cookies("g").value = "y" response.cookies("g").expires = datetime.now.addhours(1)
i change this:
request.cookies("g").value = "n"
and try destroy this
response.cookies("g").expires = datetime.now.addhours(-1)
the cookie gets set fine, cannot change value or destroy it
thanks!
try deleting way:
if (request.cookies["g"] != null) { httpcookie mycookie = new httpcookie("g"); mycookie.expires = datetime.now.adddays(-1); response.cookies.add(mycookie); }
i think if try creating cookie , adding response should work.
you want add in new cookie response has same name. recommend going day , not hour.
to change value of cookie this:
if (request.cookies["g"] != null) { httpcookie mycookie = new httpcookie("g"); mycookie.expires = datetime.now.addhours(1); mycookie.value = "n"; response.cookies.add(mycookie); }
the important thing note these examples observing read-only request collection see in there, , making changes or deleting adding new cookie replace 1 there before.
Comments
Post a Comment