Skip to content

Instantly share code, notes, and snippets.

@PilotBob
Created January 2, 2014 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PilotBob/8228138 to your computer and use it in GitHub Desktop.
Save PilotBob/8228138 to your computer and use it in GitHub Desktop.
public ActionResult SetCookies()
{
Response.Cookies.Add(new HttpCookie("Cookie1", "Test 1"));
Response.Cookies.Add(new HttpCookie("Cookie2", "Test 2"));
Response.Cookies.Add(new HttpCookie("Cookie3", "Test 3"));
return View("Index");
}
public ActionResult DeleteCookies()
{
foreach (var cookie in Request.Cookies.AllKeys)
{
var newCookie = new HttpCookie(cookie);
newCookie.Expires = DateTime.Now.AddDays(-1D);
Response.Cookies.Add(newCookie);
}
return View("Index");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment