我用下面的程序可以加不断加1,一直加到5,但我一关掉IE再从打开这页,应该是从5开始再加吧(按理他是保存在cookies文本里了),可它又从1开始!COOKIES文件夹里没有cookies:[email protected],不知道为什么不能保存??
if(Request.Cookies["nCount"] == null)
{
//初始化
HttpCookie myVale = new HttpCookie("nCount","1");
Response.AppendCookie(myVale); Response.Write("1");
}
else
{
HttpCookie cookie = Request.Cookies["nCount"];
if(cookie != null)
{

int n = int.Parse(cookie.Value) + 1; //保存更新值
HttpCookie myVale = new HttpCookie("nCount",n.ToString());
Response.AppendCookie(myVale); //输出值测试
Response.Write(cookie.Value);
}
}