C# multi-value cookies not working -
hi creating cookie in following way:
httpcookie cookie = new httpcookie("cookienamehere"); cookie.values["test1"] = "value1"; cookie.values["test2"] = "value2"; cookie.values["test3"] = "value3"; //i have tried cookie.values.add("test1", "value1"); cookie.expires = datetime.now.adddays(365d); httpcontext.current.response.appendcookie(cookie); //here have tried httpcontext.current.response.cookies.add(cookie);
but when read out cookie using following code:
httpcookie cookie = new httpcookie("cookienamehere"); cookie = httpcontext.current.response.cookies["cookienamehere"];
i cookie.values
empty
is there doing wrong here?
normally write cookie in response
, , read subsequent requests
.
i see you're trying read response
- within context of same http request, or typo?
try
httpcookie cookie = httpcontext.current.request.cookies["cookienamehere"];
Comments
Post a Comment