大家帮帮看看,这个问题好简单的。
DateTime dt = DateTime.Now;
HttpCookie mycookie2 = new HttpCookie( "logname ");
mycookie2.Value = "1111111111111111111111 ";
mycookie2.Expires = Convert.ToDateTime(dt + TimeSpan.FromDays(1));
Response.Cookies.Add(mycookie2);
if (Request.Cookies[ "mycookie2 "] != null)
{
Session[ "tx "] = Request.Cookies[ "mycookie2 "];
}
else
{
Session[ "tx "] = "aaaaaaaaaa ";
}
Response.Write(Session[ "tx "]);
Response.Write(Request.Cookies[ "mycookie2 "]);
问题:怎么老是没有付值给Cookies我快晕了。哈哈。
------解决方案--------------------倒,刚看花眼了,错在这里
if (Request.Cookies[ "logname "] != null)
{
Session[ "tx "] = Request.Cookies[ "logname "].Value;
}
else
{
Session[ "tx "] = "aaaaaaaaaa ";
}
Response.Write(Session[ "tx "]);
Response.Write(Request.Cookies[ "logname "]);
--------
"logname "不是mycookie2