/// <summary> /// Removes a cookie (by setting its Expiry one year in the past). /// </summary> /// <param name="response">The <see cref="IResponse"/> instance.</param> /// <param name="name">The name of the cookie to remove.</param> public static void RemoveCookie(this IResponse response, string name) { EnsureHeaders(response); response.AddHeader(HeaderKeys.SetCookie, CookieWriter.WriteDelete(name)); }
/// <summary> /// Sets a cookie. /// </summary> /// <param name="response">The <see cref="IResponse"/> instance.</param> /// <param name="name">The name of the cookie to set.</param> /// <param name="value">The value of the cookie to set.</param> /// <param name="timeOut">The time (in seconds) after which the cookie expires.</param> /// <param name="httpOnly">A flag indicating whether the cookie is readable only via HTTP (i.e., not by client-side script). Default is <c>true</c>.</param> /// <param name="secure">A flag indicating whether the cookie should only be sent over HTTPS. Default is <c>false</c>.</param> /// <param name="path">The path below which the cookie applies.</param> public static void SetCookie(this IResponse response, string name, string value, int timeOut = 0, bool httpOnly = true, bool secure = false, string path = "/") { response.AddHeader(HeaderKeys.SetCookie, CookieWriter.Write(name, value, timeOut, httpOnly, secure, path)); }