Code mẫu

set: HttpCookie encodedCookie = new HttpCookie(key,EncryptString.Encrypt(value)); encodedCookie.Expires = DateTime.Now.AddDays(15); HttpContext.Current.Response.Cookies.Add(encodedCookie); Get: public static string GetCookie(string key) { string value = string.Empty; HttpCookie cookie = HttpContext.Current.Request.Cookies[key]; if (cookie != null) { value = cookie.Value; } return value; }