Prevent double voting

旧街凉风 提交于 2019-12-04 23:39:21

问题


I'm creating a web application where users will vote for some candidates by clicking thumbs up or thumbs down, and these users won't have any account on the site.

What is the best technique to use? Is it necessary to use captcha for more protection from spam?

Vote counts are expected to be millions, and the subject is not very critical as long as I get 95% accuracy that would be fine. Thanks.


回答1:


You can combine these two methods:

  • Add a cookie to prevent multiple votes from the same machine
  • Log IP addresses and prevent voting more than a set number of times from the same address (for example, 5 times the same hour).

This will make it possible for multiple persons to vote from the same network but still prevent excessive cheating.

You may also make it harder to build a voting bot by adding some hidden form field with a token that must be included in the vote, and/or use Ajax for the voting. I know it's relatively easy to build a bot anyway but most cheaters aren't that smart.




回答2:


Cookies and Session Ids will help, although both can be lost when the browser is closed (if the user has it enabled to delete them). Still, they will give you some degree of accuracy (ex. the lazy voters won't bother to close and reopen their browsers).

Using IP Addresses would also work, but as @Michael Dillon said people on the same IP address (same router) will not be able to vote.




回答3:


You have several options, some or all of which you can use.

You can record IP and then check against IP, but then this isn't indicative of a specific person just a computer and sometimes not just a single computer.

You can also write a cookie to a user's browser but a user can use a different browser, machine etc.

Within a user's session you could create a session variable, although if you are expecting very high traffic this may not be the best option, and also only prevents re-voting within the same session.

If you are contemplating a captcha, you may as well ask the user to supply an email address and then you are assured of at least one vote per email address. However, even then you cannot be guaranteed valid email addresses.



来源:https://stackoverflow.com/questions/8962562/prevent-double-voting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!