I have an <asp:CheckBox OnClick="">
linked to a JavaScript function that sets a cookie value like this:
document.cookie = "cv0_value=1";
In my .Net code-behind, I am retrieving the cookie value using the following code, and everything seems to be functioning correctly.
cv0_value = Request.Cookies["cv0_value"].Value == "0" ? false : true;
The problem arises when I try to update the cookie value in the .Net code-behind - it does not seem to change the actual cookie value.
HttpContext.Current.Request.Cookies["cv0_value"].Value = "0";
Upon checking the cookie value again in the code-behind, I notice that it remains set to the original value assigned by the JavaScript.
Even after multiple calls to the Page_Load method and reviewing the Request and Response, the updated value is not reflected in the cookie. Despite setting the Response with the new value, on subsequent Page_Load calls, the Request still contains the initial value.
Although I initially thought the issue might be related to referencing from a static method, further exploration revealed that the use of HttpContext.Current.Response does not seem to be causing the problem in my specific case as detailed here. Can anyone shed light on what could be happening?