[关于cookies值的过期问题]
代码片断1:
HttpCookie ck = new HttpCookie( "Blog ");
ck.Values.Add( "ID ", mod_UserInfo.ID.ToString());
ck.Values.Add( "Name ", mod_UserInfo.Name.ToString());
ck.Values.Add( "GroupID ", mod_UserInfo.GroupID.ToString());
ck.Expires = DateTime.Now.AddDays(10);
Response.AppendCookie(ck);
Response.Redirect( "~/Default.aspx ");
代码片断2(defalut.aspx):
if (Request.Cookies[ "Blog "] != null)
{
lblUserName.Text = Request.Cookies[ "Blog "].Expires.ToString();
}
结果:
lblUserName.Text=“001-01-01 00:00:00”怎么会是这样呢?代码1中的Expires值我跟踪调试过确认是有值的,怎么跳转一个页面其它值都在就是这个值丢失了呢?
------解决方案--------------------似乎无法读取cookies的过期时间