Adding a cookie without an expiration in ASP.NET causes the cookie to expire at the end of the session. But to update the cookie is there anything special I have to do? I have seen suggestions to set the existing cookie to expire in the past, update the existing cookies expiration date, or simply update the value of the cookie. I tried simply updating the value of the existing cookie but this does not seem to be doing anything in Fiddler. Is there one right way to update a cookie’s value in memory with ASP.NET?
Share
You need to send a new cookie to the browser. So read the cookie from the request, change the value and add it to the response.
This sends a set-cookie header back to the client which as it has the same name overrides the one cached by the browser. next time it’ll send the new cookie.
Simon