为什么生成不了COOKIE?????
HttpCookie UserName=new HttpCookie( "UserName ");
UserName.Value= "9987 ";
Response.Cookies.Add(UserName);
这段代码有问题吗????为什么生成不了COOKIE?????机器没有禁用啊...
[解决办法]
再加上下面的代码查看一个值对吗?
Label1.Text=(string)Response.Cookies[ "UserName "].Value;
[解决办法]
System.Web.Security.FormsAuthentication.SetAuthCookie(username, false);
Response.Cookies[ "UserInfo "][ "UserName "] = username;
Response.Cookies[ "UserInfo "].Expires = DateTime.Now.AddMinutes(double.Parse( "60 "));
[解决办法]
因为你没有设置Cookies的有效时间~立刻就被清除了~
后面加上UserName.Expires = DateTime.Now.AddDays(30);
[解决办法]
定义一个单Cookie并赋值,在关闭浏览器就清除这个Cookie可以用
Response.Cookies[ "CookieName "].Value = "Cookie值 ";
用
Request.Cookies[ "CookieName "].Value
来获取值