Here is the scenario. A cookie with the key "MyCookie"
has been set on a previous request. I can access it via HttpContext.Request.Cookies.Get("MyCookie")
. I want to perform an update such as adding another value to the Cookie Values collection, but I'm not 100% sure I am doing it right.
Am I doing this correctly in the following example?
public static void UpdateCookie(HttpContext context, string cookieName, Action<HttpCookie> updateCookie){
var cookie = context.Request.Cookies.Get(cookieName);
updateCookie(cookie);
context.Response.Cookies.Set(cookie);
}