一、写入:

 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"]);
            }

 

 

相关文章:

  • 2021-06-07
  • 2022-12-23
  • 2021-12-01
  • 2021-08-19
  • 2021-08-07
  • 2021-07-07
  • 2021-11-18
  • 2021-07-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2021-12-03
  • 2021-07-03
  • 2022-12-23
相关资源
相似解决方案