public HttpResponseMessage Delete(string token) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); if (sessionServices.Delete(token)) { #region Please implement the method removing the cookie // Please clear the session cookie from the browser. var currentCookie = Request.Headers.GetCookies("Set-Cookie").FirstOrDefault(); if (currentCookie != null) { var cookie = new CookieHeaderValue("Set-Cookie", "") { Expires = DateTimeOffset.Now.AddDays(-1), Domain = currentCookie.Domain, Path = currentCookie.Path }; response.Headers.AddCookies(new [] { cookie }); } #endregion } return(response); }
public HttpResponseMessage Delete(string token) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); if (sessionServices.Delete(token)) { #region Please implement the method removing the cookie // Please clear the session cookie from the browser. sessionServices.Delete(token); var cookie = new CookieHeaderValue(SessionCookieKey, "") { Expires = DateTimeOffset.MinValue }; response.Headers.AddCookies(new [] { cookie }); #endregion } return(response); }
public HttpResponseMessage Delete(string token) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); if (sessionServices.Delete(token)) { #region Please implement the method removing the cookie // Please clear the session cookie from the browser. throw new NotImplementedException(); #endregion } return(response); }
public HttpResponseMessage Delete(string token) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); if (sessionServices.Delete(token)) { response.Headers.AddCookies( new[] { new CookieHeaderValue(SessionCookieKey, "") { Expires = new DateTimeOffset(1990, 1, 1, 0, 0, 0, TimeSpan.Zero) } }); } return(response); }