日期:2014-05-17 浏览次数:20484 次
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HttpCookie oldCookie = Request.Cookies["Time"];//判断Time的cookie if (oldCookie != null) { if (DateTime.Now.ToString("yyyy-MM-dd") == Convert.ToDateTime(oldCookie.Values["GetTime"]).ToString("yyyy-MM-dd")) //如果当前日期和cookie的日期相同 { IsEnable = true; this.IsGet.Value = "false"; } else { HttpCookie newCookie = new HttpCookie("Time");//新建Time的cookie newCookie.Values.Add("GetTime", DateTime.Now.Date.ToString("yyyy-MM-dd"));//给cookie添加当前日期 Response.Cookies.Add(newCookie); //写入cookie } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HttpCookie oldCookie = Request.Cookies["Time"];//判断Time的cookie if (oldCookie != null) { if (DateTime.Now.ToString("yyyy-MM-dd") == Convert.ToDateTime(oldCookie.Values["GetTime"]).ToString("yyyy-MM-dd")) //如果当前日期和cookie的日期相同 { IsEnable = true; this.IsGet.Value = "false"; } else { HttpCookie newCookie = new HttpCookie("Time");//新建Time的cookie newCookie.Values.Add("GetTime", DateTime.Now.Date.ToString("yyyy-MM-dd"));//给cookie添加当前日期 [color=#FF0000]newCookie.Expires = DateTime.Now.AddHours(24.0);[/color] Response.Cookies.Add(newCookie); //写入cookie } } } }
------解决方案--------------------
记录到文件或注册表
------解决方案--------------------