ASP.net写入和读取Cookies

一、写入:

 HttpCookie cook = new HttpCookie("abcname");
                cook.Expires = DateTime.Now.AddYears(1);//设定过期时间
                cook["username"] = user.Uname;
                Response.Cookies.Add(cook);

二、读取:

            HttpCookie cook = Request.Cookies["abcname"];
            string name = string.Empty;
            if (cook != null)
            {
                name = Convert.ToString(cook["username"]);
            }
原文地址:https://www.cnblogs.com/xdpxyxy/p/2815984.html