日期:2014-05-16 浏览次数:20461 次
HttpCookie c = Request.Cookies["User_Time"];
if (c == null)
{
string Time = DateTime.Now.ToString();
HttpCookie hc = new HttpCookie("User_Time", Time);
Response.AppendCookie(hc);
Response.Redirect(Request.Url.ToString());
}
else
{
Response.Write("现在的时间:" + DateTime.Now.ToString() + "<br/>");
Response.Write("上次登录的时间:" + c.Value + "<br/>");
//更新cookie
c.Value = DateTime.Now.ToString();
Response.Cookies.Set(c);
Response.Write("RequestCookie:" + Request.Cookies["User_Time"].Value);
}
Response.Write("现在的时间:" + DateTime.Now.ToString() + "<br/>");
Response.Write("上次登录的时间:" + c.Value + "<br/>");
//更新cookie
c.Value = DateTime.Now.ToString();
Response.Write("RequestCookie:" + Request.Cookies["User_Time"].Value);