现在的位置: 首页 > 综合 > 正文

.net写入Cookie访问计数器

2018年02月02日 ⁄ 综合 ⁄ 共 656字 ⁄ 字号 评论关闭
    <%    
            int last=0;
            string str = Request.Cookies["last"].Value;
            last = int.Parse(str);
            if (last != null)
            {
                Response.Write(last);
                HttpCookie acookie = new HttpCookie("last");
                acookie.Value = (last+1).ToString();
                acookie.Expires = DateTime.MaxValue;
                Response.Cookies.Add(acookie);
            }
            else
            {
                Response.Write("0");
                HttpCookie acookie = new HttpCookie("last");
                acookie.Value = "1";
                acookie.Expires = DateTime.MaxValue;
                Response.Cookies.Add(acookie);
            }
    %>
【上篇】
【下篇】

抱歉!评论已关闭.