I'm trying to modify the value of my cookie but It doesn't modify instead it appends. What am I doing wrong?
Currently, SkillId
cookie contains 112 in value, I want to update its value with whatever is in my variable qualifyBySkill
.
string qualifyBySkill = "189";
HttpCookie cookie = Request.Cookies["SkillId"];
if (cookie != null)
{
cookie.Values["SkillId"] = qualifyBySkill;
}
cookie.Expires = DateTime.UtcNow.AddDays(1);
Response.Cookies.Add(cookie);
What happens is, after this code it sets 112&SkillId=189 instead of 189 in Value. What am i doing wrong?