C#中Cookie的写入与读取
作者:互联网
HttpCookie cookie = new HttpCookie("guid"); //创建
cookie.Values["id"] = “123456789”; //将“123456789”写入id
HttpContext.Current.Response.AppendCookie(cookie); //保存
HttpCookie cookie = HttpContext.Current.Request.Cookies[“guid”]; //读取
string id = cookie.Values["id"].ToString(); //id="123456789"
cookie.Expires 可以设置过期时间,一般不进行设置默认关闭浏览器后失效
标签:读取,C#,Current,123456789,cookie,HttpCookie,Cookie,guid,id 来源: https://www.cnblogs.com/Net191111/p/14096769.html