Skip to content

Instantly share code, notes, and snippets.

@normansolutions
Last active September 17, 2015 20:58
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 normansolutions/d7d28220fc03f03ce345 to your computer and use it in GitHub Desktop.
Save normansolutions/d7d28220fc03f03ce345 to your computer and use it in GitHub Desktop.
@{
String cookieQueryString = Request.QueryString["cookieSetter"];
switch (cookieQueryString)
{
@* QueryString "remove" - This deletes the cookie from the device *@
case "remove":
Response.Cookies["NSSecureMethodCookie"].Expires = DateTime.Now.AddYears(-30);
break;
@* QueryString "add" - This creates the cookie on the device *@
case "add":
HttpCookie aCookie = new HttpCookie("NSSecureMethodCookie");
aCookie.HttpOnly = true;
aCookie.Value = "Authorised";
aCookie.Expires = DateTime.Now.AddYears(30);
Response.Cookies.Add(aCookie);
break;
}
}
@* Visual feedback for cookie *@
@if (Request.Cookies["NSSecureMethodCookie"] != null)
{
Response.Write("Cookie Found");
Response.Write("<br/>");
Response.Write(Request.Cookies["NSSecureMethodCookie"].Value);
Response.Write("<br/>");
Response.Write(Request.Cookies["NSSecureMethodCookie"].Expires);
Response.Write("<br/>");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment