Beispiel #1
0
 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());
     }
 }
Beispiel #2
0
 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());
     }
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }