Prevent voting twice

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
scarface222
Forum Contributor
Posts: 354
Joined: Thu Mar 26, 2009 8:16 pm

Prevent voting twice

Post by scarface222 »

Hey guys quick question. I was wondering if anyone had a suggestion on how to prevent users voting twice on my vote script. I am not really sure what the best method to use is. Would it be better to try to use cookies or some kind of session variable? IF anyone has any advice I would really appreciate it.
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Prevent voting twice

Post by JakeJ »

Why reinvent the wheel. There are several open source polling and survey packages available. At the very least take a look at their methods and copy then if you insist on rolling your own.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Prevent voting twice

Post by Benjamin »

Really, the only semi-perfect solution is to track IP addresses. You can store them in a table permanently or cache them for a period of time in Memcache or similar. Of course, if the users are logged in, the best method is to simply check if the user has voted or not yet.

Sessions and Cookies are useless because one could simply write an automated voting algorithm that ignores session data.
Post Reply