protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
int a;
if ( Request.Cookies["a"] == null)
{
a = 0;
}
else
{
a = int.Parse(Request.Cookies["a"].Value);
}
a++;
HttpCookie aCookie = new HttpCookie("a");
aCookie.Value = a.ToString();
aCookie.Expires = DateTime.MaxValue;
Response.Cookies.Add(aCookie);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Request.Cookies["a"] == null)
{
TextBox1.Text = "1";
}
else
{
HttpCookie aCookie = Request.Cookies["a"];
TextBox1.Text = Server.HtmlEncode(aCookie.Value);
}
}
记录IP登录的次数
最新推荐文章于 2021-12-22 16:22:00 发布