public override void SetUser(string key, object value, DateTime expirationDate) { if (key == String.Empty) { throw new ArgumentException("The provided key cannot be null or String.Empty."); } if (key != String.Empty && HttpContext.Current != null && HttpContext.Current.Request != null) { string encryptedValue = CookieCrypter.Encrypt(key, value.ToString(), expirationDate); HttpCookie cookie = new HttpCookie(key, encryptedValue); cookie.Path = StateAccess.State.ApplicationPath; if (expirationDate > DateTime.MinValue) { cookie.Expires = expirationDate; } HttpContext.Current.Response.Cookies.Add(cookie); } }
public override object GetUser(string key) { if (key == String.Empty) { throw new ArgumentException("The provided key cannot be null or String.Empty."); } if (key != String.Empty && HttpContext.Current != null && HttpContext.Current.Request != null) { HttpCookie cookie = HttpContext.Current.Request.Cookies[key]; if (cookie != null) { return(CookieCrypter.Decrypt(cookie.Value)); } } return(null); }