日期:2014-05-17 浏览次数:20547 次
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HttpCookie cookie = Request.Cookies["userSName"]; if (cookie != null ) { Response.Write(cookie + " :1"); } else { Response.Write(cookie +" :2"); } } }
HttpCookie cookie = new HttpCookie("UserName", "test"); Response.Cookies.Add(cookie); HttpCookie ck = Request.Cookies["UserName"]; if (ck != null) { Response.Write(ck.Value + ":1"); } else { Response.Write("cookie不存在"); }
------解决方案--------------------
IE清除缓存后需要关掉重新打开。