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); }
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); } }
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); }
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); }
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); }
public static bool CookieIsExist(CookieKeys key) { if (HttpContext.Current.Request.Cookies[key.ToString()] != null) { return(true); } return(false); }
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()); }
public static void SetCookie(CookieKeys key, string ownedToken) { HttpCookie savingCookie = new HttpCookie(key.ToString(), ownedToken); HttpContext.Current.Response.Cookies.Add(savingCookie); }