public static void SetCookies(CookiesType type, string value, string domain, bool session = false)
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            HttpContext.Current.Response.Cookies[GetCookiesName(type)].Value   = value;
            HttpContext.Current.Response.Cookies[GetCookiesName(type)].Domain  = domain;
            HttpContext.Current.Response.Cookies[GetCookiesName(type)].Expires = GetExpiresDate(session);

            if (type == CookiesType.AuthKey)
            {
                HttpContext.Current.Response.Cookies[GetCookiesName(type)].HttpOnly = true;

                if (HttpContext.Current.Request.GetUrlRewriter().Scheme == "https")
                {
                    HttpContext.Current.Response.Cookies[GetCookiesName(type)].Secure = true;
                    if (CoreContext.Configuration.Personal)
                    {
                        var cookies = HttpContext.Current.Response.Cookies[GetCookiesName(type)];

                        cookies.GetType()
                        .GetProperty("SameSite")
                        .SetValue(cookies, 0);
                    }
                }
            }
        }
 public static void ClearCookies(CookiesType type)
 {
     if (HttpContext.Current != null)
     {
         if (HttpContext.Current.Request.Cookies[GetCookiesName(type)] != null)
             HttpContext.Current.Response.Cookies[GetCookiesName(type)].Expires = DateTime.Now.AddDays(-3);
     }
 }
 public static string GetRequestVar(CookiesType type)
 {
     if (HttpContext.Current!=null)
     {
         var cookie = HttpContext.Current.Request.QueryString[GetCookiesName(type)] ?? HttpContext.Current.Request.Form[GetCookiesName(type)];
         return string.IsNullOrEmpty(cookie) ? GetCookies(type) : cookie;
     }
     return "";
 }
Beispiel #4
0
 public static string GetRequestVar(CookiesType type)
 {
     if (HttpContext.Current != null)
     {
         var cookie = HttpContext.Current.Request.QueryString[GetCookiesName(type)] ?? HttpContext.Current.Request.Form[GetCookiesName(type)];
         return(string.IsNullOrEmpty(cookie) ? GetCookies(type) : cookie);
     }
     return("");
 }
Beispiel #5
0
        private static string GetCookiesName(CookiesType type)
        {
            switch (type)
            {
            case CookiesType.AuthKey: return(AuthCookiesName);
            }

            return(string.Empty);
        }
Beispiel #6
0
        private static string GetCookiesName(CookiesType type)
        {
            return(type switch
            {
                CookiesType.AuthKey => AuthCookiesName,
                CookiesType.SocketIO => SocketIOCookiesName,

                _ => string.Empty,
            });
Beispiel #7
0
 public static void ClearCookies(CookiesType type)
 {
     if (HttpContext.Current != null)
     {
         if (HttpContext.Current.Request.Cookies[GetCookiesName(type)] != null)
         {
             HttpContext.Current.Response.Cookies[GetCookiesName(type)].Expires = DateTime.Now.AddDays(-3);
         }
     }
 }
        private static string GetCookiesName(CookiesType type)
        {
            switch (type)
            {
                case CookiesType.AuthKey: return AuthCookiesName;
                case CookiesType.NoMobile: return NoMobileCookiesName;
            }

            return string.Empty;
        }
 public static void SetCookies(CookiesType type, string value)
 {
     if (HttpContext.Current != null)
     {
         HttpContext.Current.Response.Cookies[GetCookiesName(type)].Value = value;
         HttpContext.Current.Response.Cookies[GetCookiesName(type)].Expires = DateTime.Now.AddDays(365);
         if (type==CookiesType.AuthKey)
         {
             HttpContext.Current.Response.Cookies[GetCookiesName(type)].HttpOnly = true;
         }
     }
 }
Beispiel #10
0
 public static void SetCookies(CookiesType type, string value, bool session = false)
 {
     if (HttpContext.Current != null)
     {
         HttpContext.Current.Response.Cookies[GetCookiesName(type)].Value   = value;
         HttpContext.Current.Response.Cookies[GetCookiesName(type)].Expires = session ? DateTime.MinValue : DateTime.Now.AddDays(365);
         if (type == CookiesType.AuthKey)
         {
             HttpContext.Current.Response.Cookies[GetCookiesName(type)].HttpOnly = true;
         }
     }
 }
Beispiel #11
0
        public static string GetCookies(CookiesType type)
        {
            if (HttpContext.Current != null)
            {
                var cookieName = GetCookiesName(type);
                if (HttpContext.Current.Response.Cookies.AllKeys.Contains(cookieName))
                    return HttpContext.Current.Response.Cookies[cookieName].Value ?? "";

                if (HttpContext.Current.Request.Cookies[cookieName] != null)
                    return HttpContext.Current.Request.Cookies[cookieName].Value ?? "";
            }
            return "";
        }
 public static void SetCookies(CookiesType type, string value, string domain, bool session = false)
 {
     if (HttpContext.Current != null)
     {
         HttpContext.Current.Response.Cookies[GetCookiesName(type)].Value = value;
         HttpContext.Current.Response.Cookies[GetCookiesName(type)].Domain = domain;
         HttpContext.Current.Response.Cookies[GetCookiesName(type)].Expires = session ? DateTime.MinValue : DateTime.Now.AddDays(365);
         if (type == CookiesType.AuthKey)
         {
             HttpContext.Current.Response.Cookies[GetCookiesName(type)].HttpOnly = true;
         }
     }
 }
Beispiel #13
0
        public static string GetCookies(CookiesType type)
        {
            if (HttpContext.Current != null)
            {
                var cookieName = GetCookiesName(type);

                if (HttpContext.Current.Request.Cookies[cookieName] != null)
                {
                    return(HttpContext.Current.Request.Cookies[cookieName].Value ?? "");
                }
            }
            return("");
        }
Beispiel #14
0
 public static void SetCookies(CookiesType type, string value, string domain)
 {
     if (HttpContext.Current != null)
     {
         HttpContext.Current.Response.Cookies[GetCookiesName(type)].Value   = value;
         HttpContext.Current.Response.Cookies[GetCookiesName(type)].Domain  = domain;
         HttpContext.Current.Response.Cookies[GetCookiesName(type)].Expires = DateTime.Now.AddDays(365);
         if (type == CookiesType.AuthKey)
         {
             HttpContext.Current.Response.Cookies[GetCookiesName(type)].HttpOnly = true;
         }
     }
 }
        private static string GetCookiesName(CookiesType type)
        {
            switch (type)
            {
                case CookiesType.AuthKey: return AuthCookiesName;
                case CookiesType.UserID: return UidCookiesName;
                case CookiesType.EmployeeViewMode: return EmpViewModeCookiesName;
                case CookiesType.MinimizedNavpanel: return MinimizedNavpanel;
                case CookiesType.NoMobile:
                    return NoMobileCookiesName;
            }

            return string.Empty;
        }
Beispiel #16
0
        public static void SetCookies(CookiesType type, string value, bool session = false)
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            HttpContext.Current.Response.Cookies[GetCookiesName(type)].Value   = value;
            HttpContext.Current.Response.Cookies[GetCookiesName(type)].Expires = GetExpiresDate(session);

            if (type == CookiesType.AuthKey)
            {
                HttpContext.Current.Response.Cookies[GetCookiesName(type)].HttpOnly = true;
            }
        }
Beispiel #17
0
        private static string GetCookiesName(CookiesType type)
        {
            switch (type)
            {
            case CookiesType.AuthKey: return(AuthCookiesName);

            case CookiesType.UserID: return(UidCookiesName);

            case CookiesType.EmployeeViewMode: return(EmpViewModeCookiesName);

            case CookiesType.MinimizedNavpanel: return(MinimizedNavpanel);

            case CookiesType.NoMobile:
                return(NoMobileCookiesName);
            }

            return(string.Empty);
        }
Beispiel #18
0
        public static void SetCookies(CookiesType type, string value, string domain, bool session = false)
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            HttpContext.Current.Response.Cookies[GetCookiesName(type)].Value   = value;
            HttpContext.Current.Response.Cookies[GetCookiesName(type)].Domain  = domain;
            HttpContext.Current.Response.Cookies[GetCookiesName(type)].Expires = GetExpiresDate(session);

            if (type == CookiesType.AuthKey)
            {
                HttpContext.Current.Response.Cookies[GetCookiesName(type)].HttpOnly = true;

                if (HttpContext.Current.Request.GetUrlRewriter().Scheme == "https")
                {
                    HttpContext.Current.Response.Cookies[GetCookiesName(type)].Secure = true;
                }
            }
        }