public static T GetCookie <T>(this HttpContext context, string name) where T : class { HttpCookie cookie = context.Request.Cookies[name]; if (!cookie.IsNull()) { return(HttpUtility.UrlDecode(cookie.Value).FromJson <T>()); } return(null); }
public static void RemoveCookie(this HttpContext context, string domain, string name) { HttpCookie cookie = context.Request.Cookies[name]; if (!cookie.IsNull()) { cookie.Domain = domain; cookie.Expires = DateTime.Today.AddDays(-1); context.Response.Cookies.Add(cookie); } }
static bool ValidateCookie(HttpCookie authCookie) { var invalid = authCookie.IsNull() || authCookie.Value.Blank(); return !invalid; }