예제 #1
0
 public static string GetCurrentToken(CookieKeys key)
 {
     if (HttpContext.Current.Request.Cookies[key.ToString()] != null)
     {
         string token = HttpContext.Current.Request.Cookies[key.ToString()].Value;
         return(token);
     }
     return(null);
 }
예제 #2
0
 public static void ExpireCookie(CookieKeys key, int timeMonthAmount)
 {
     HttpContext.Current.Session.Abandon();
     if (HttpContext.Current.Request.Cookies[key.ToString()] != null)
     {
         HttpCookie currentCookie = new HttpCookie(key.ToString());
         currentCookie.Expires = DateTime.Now.AddMonths(timeMonthAmount);
         HttpContext.Current.Response.Cookies.Add(currentCookie);
     }
 }
예제 #3
0
        public static string GetCurrentUrl(CookieKeys key)
        {
            string url = "MyEvernoteHome/Index";

            if (HttpContext.Current.Request.Cookies[key.ToString()] != null)
            {
                url = HttpContext.Current.Request.Cookies[key.ToString()].Value;
            }

            return(url);
        }
예제 #4
0
        public static User GetCurrentUser(CookieKeys key)
        {
            UserManager _usm = new UserManager();

            if (HttpContext.Current.Request.Cookies[key.ToString()] != null)
            {
                string token = HttpContext.Current.Request.Cookies[key.ToString()].Value;
                User   user  = _usm.Get(x => x.Token.ToString() == token);
                return(user);
            }
            return(null);
        }
예제 #5
0
        private void Set(CookieKeys key, string value)
        {
            HttpCookie cookie = new HttpCookie(key.ToString());

            cookie.Expires = DateTime.Now.AddMonths(1);
            cookie.Value   = value;

            HttpContext.Current.Response.SetCookie(cookie);
        }
예제 #6
0
        public static bool CookieIsExist(CookieKeys key)
        {
            if (HttpContext.Current.Request.Cookies[key.ToString()] != null)
            {
                return(true);
            }

            return(false);
        }
예제 #7
0
        private string Get(CookieKeys key)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[key.ToString()];

            return(cookie == null ? null : cookie.Value);
        }
 public void DeleteCookie(CookieKeys key)
 {
     this.DeleteCookie(key.ToString());
 }
 public string GetCookie(CookieKeys key)
 {
     return(this.GetCookie(key.ToString()));
 }
 public void SetCookie(string value, CookieKeys key)
 {
     this.SetCookie(value, key.ToString());
 }
예제 #11
0
        public static void SetCookie(CookieKeys key, string ownedToken)
        {
            HttpCookie savingCookie = new HttpCookie(key.ToString(), ownedToken);

            HttpContext.Current.Response.Cookies.Add(savingCookie);
        }