void SetCookie(string value) { DateTime?expires = null; if (String.IsNullOrWhiteSpace(value)) { var existingValue = GetCookie(); if (existingValue == null) { // no need to write cookie to clear if we don't already have one return; } value = "."; expires = DateTime.Now.AddYears(-1); } var opts = new Microsoft.AspNet.Http.CookieOptions { HttpOnly = true, Secure = Secure, Path = CookiePath, Expires = expires }; _context.HttpContext.Response.Cookies.Append(CookieName, value, opts); }
void SetCookie(string value) { DateTime? expires = null; if (String.IsNullOrWhiteSpace(value)) { var existingValue = GetCookie(); if (existingValue == null) { // no need to write cookie to clear if we don't already have one return; } value = "."; expires = DateTime.Now.AddYears(-1); } var opts = new Microsoft.AspNet.Http.CookieOptions { HttpOnly = true, Secure = Secure, Path = CookiePath, Expires = expires }; _context.HttpContext.Response.Cookies.Append(CookieName, value, opts); }