一、Cookie
设置 cookie
HttpCookie cookie = new HttpCookie(name);
cookie.Value = user.UserID.ToString();
Response.Cookies.Add(cookie);
读取cookie
System.Web.HttpContext.Current.Request.Cookies[name].Value
二、Session
设置session
HttpContext.Current.Session.Add(name, value);
根据session名获取session对象
HttpContext.Current.Session[name];
cookie和session的设置和读取,布布扣,bubuko.com
时间: 2024-10-25 18:53:46