1. if (Request.Cookies["tp"] != null && Request.Cookies["tp"].Value == "true")  
  2.         {  
  3.             Alert("您已经投票过了!");  
  4.             return;  
  5.         }  
  6.   
  7.   
  8.         HttpCookie cookie = new HttpCookie("tp");  
  9.         cookie.Value = "true";  
  10.         cookie.Expires = DateTime.Now.AddSeconds(10);  
  11.         Response.Cookies.Add(cookie);  
  12.         Alert("投票成功!");  

 

原理就是:
1、判断cookie中的某个指是否存在,该值表示是否投票过,存在则弹出提示已经投票过,退出执行
2、不存在,可以投票,建立cookie,上面的代码是设置cookie的过期时间是10秒后
   
    这样就只能是10秒以内才能投票一次

相关文章:

  • 2021-05-13
  • 2021-11-06
  • 2021-06-06
  • 2021-11-22
  • 2021-09-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2021-08-13
  • 2022-12-23
相关资源
相似解决方案