public static void Set(this Microsoft.AspNetCore.Http.IResponseCookies cookies, string key, string value, CookieOptions options = null) { if (options != null) { cookies.Append(key, value.Encode(), options); } else { cookies.Append(key, value.Encode()); } }
public static void Set <T>(this Microsoft.AspNetCore.Http.IResponseCookies cookies, string key, T value, CookieOptions options = null) { if (options != null) { cookies.Append(key, Newtonsoft.Json.JsonConvert.SerializeObject(value).Encode(), options); } else { cookies.Append(key, Newtonsoft.Json.JsonConvert.SerializeObject(value).Encode()); } }
public static void Set <T>(this Microsoft.AspNetCore.Http.IResponseCookies cookies, string key, T value, int?Expires, bool HttpOnly = true) { var options = new CookieOptions(); if (Expires.HasValue) { options.Expires = DateTime.Now.AddMinutes(Expires.Value); } else { options.Expires = DateTime.Now.AddMinutes(1); } options.HttpOnly = HttpOnly; cookies.Append(key, Newtonsoft.Json.JsonConvert.SerializeObject(value).Encode(), options); }
public static void Set(this Microsoft.AspNetCore.Http.IResponseCookies cookies, string key, string value, int?Expires, bool HttpOnly = true) { var options = new CookieOptions(); if (Expires.HasValue) { options.Expires = DateTime.Now.AddMinutes(Expires.Value); } else { options.Expires = DateTime.Now.AddMinutes(1); } options.HttpOnly = HttpOnly; cookies.Append(key, value.Encode(), options); }