Cristian E.
Cristian E.

Reputation: 3583

How to replace a HttpCookie in MVC3

The question is quite straightforward:

How to replace a HttpCookie in MVC3? (Assuming we have access to the HttpContext instance)

Upvotes: 0

Views: 163

Answers (1)

James
James

Reputation: 82136

Use SetCookie

var cookie = Request.Cookies["cookieName"];
if (cookie != null)
{
    cookie.Value = "new value";
    Response.SetCookie(cookie);
}

Upvotes: 1

Related Questions