创建Cookie 时候必须命名全部路径

 

View Code
1 HttpCookie UserCookie = new HttpCookie("User");
2                     UserCookie["UserID"] = 1;
3              System.Web.HttpContext.Current.Response.Cookies.Add(UserCookie);

 

获取Cookie值

 

View Code
1 HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies["User"];
2 string id = cookie.Values["UserID"];

 

posted on 2012-06-20 15:10  吴勇寿  阅读(1989)  评论(0编辑  收藏  举报