写入Cookie

写入Cookie

        private void SetCookie(string domain)
        {
            HttpCookie cookie = new HttpCookie("token");
            if (!string.IsNullOrEmpty(domain))
                cookie.Domain = domain;
            cookie.Path = "/";
            cookie.Expires = DateTime.Now.AddDays(7);
            cookie.Values.Add("key", "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
            Response.Cookies.Add(cookie);
        }

你可能感兴趣的:(cookie)