开发者

Unique IPs in a voting system

I'm creating a voting system 开发者_StackOverflow社区for my PHP/MySQL website and I would like to make sure one user can only vote once. What would be a good way of doing this? So far I have thought of and semi-implemented the following:

  • Storing individual votes in the database with an IP and vote. This creates bulkiness but ensures that each user gets one vote.

  • Storing a cookie on the user's end to check if they've voted or not. This is the most simple but obviously users can just disable cookies.

What would be the most practical approach? Any other suggestions are more than welcome.


The Unobtainably-Perfect: (Unique Govt Number)

  • User votes using a verifiable unique identifier like a social-security or passport number

The Close-Enough-For-Reality: (Email/3rd Party Auth)

  • user registers an account with an email address and password (or google/facebook)
  • 1 email address = 1 vote
  • Users can't clear cookies and get extra votes, App doesn't shut 1000's out with shared IPs

The Good-Thought-But-False-Pretense (IP addresses)

  • Office buildings: 1000's of users on the same external IP get shut-out
  • Universites: Connect to wireless in classroom. Vote. Move to next classroom. Reconnect and vote again

The Crash-And-Burn (Cookies)

  1. Vote
  2. ctrl shft del enter
  3. vote
  4. repeat


You should store as much information as you can in a database if you want to have any chance of auditing your system. If you log a lot, then even if there has been voting fraud you might be able to detect it and cancel those votes.

The second method is completely insecure. Users can just delete the cookie if they want to vote again and you will have no way to detect that this has happened.

Important note

There is not a one-to-one mapping between IP addresses an people. Some people have many IP addresses, whilst other people share a single IP address.


A fully reliable way is going to be tricky. Both your ideas have problems - cookies can be disabled, and one user may have many IP's and/or many users may share the same IP. Forcing your users to register and only allowing one vote per registered account would be better, but then someone might signup for multiple accounts. Forcing unique email verification for each account reduces this somewhat, but you could still get around it by signing up for multiple different emails.

Basically, each measure you take makes it more difficult to get around, but also increases the effort of voting at all in the first place. Short of tying votes to something known unique (SSN, passport number) that can be verified, any measure you put in place can be circumvented, it just depends on how much effort it is. Manually reviewing suspicious looking votes would help to reduce fraudulent votes too though, in addition to other measures. Where you drawn the line between ease-of-use and security is up to you really, depending on how much you need to enforce the one vote limit.


As Mark Byers said, some countries might have dynamic IP addresses (e.g. Vietnam) so the IP addresses will consistently change every time a user establishes a connection (or reset the modem). But if you can ensure that your system is built in a country where IP addresses are static, then it's fine.

The cookies solution seems to be a bit insecure, but if most of your users are non-tech people then they won't be able to recognize the trick (which is to delete the cookies and vote again). For me I don't prefer this way as long as I know my users don't know anything about this technique.

I suggest you to have email verification for the poll, so that the results will be more accurate. A user might only have a few email addresses, and they don't want to create new ones just to vote.


Whatever it is you decide to go with, IP addresses will not be secure at all. A user can basically access from a different location and vote again etc. Cookie is a solution but not optimized because of deleting possibility (so u risk the user recognition process). You will need to handle more data from the user to be able record their option securely.

if the system is a sub-system of a bigger system, maybe you can use a field that is common in bigger system to identify users in current system.

Hope this helps,


The only way to make sure users vote only once is to create user accounts Because:

Cookies can be erased

IP address are meant to change. (also, multiple users could have one IP address)


Storing individual votes in the database with an IP and vote. This creates bulkiness but ensures that each user gets one vote.

That is Good but slow than 2nd but still i recommend this.

Storing a cookie on the user's end to check if they've voted or not. This is the most simple but obviously users can just disable cookies.

you're right its insecure but little faster but i don't like this

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜