cookies

int num = 0;
        try
        {
            num = int.Parse(Request.Cookies["visitnum"].Value);

        }
        catch (Exception)
        {

            num = 0;
        }
        if (num > 0)
        {
            num++;
            Response.Write("您这是第" + num.ToString() + "次访问本站点了。");
        }
        else
        {
            Response.Write("欢迎访问该网站");
            num = 1;
        }
        Response.Cookies["visitnum"].Value = num.ToString();
        Response.Cookies["visitnum"].Expires = DateTime.Now.AddDays(364);

你可能感兴趣的:(Cookies)