Im working on a website (html,css,javascript, ajax, php,mysql), and I want to restrict the number of times a particular user votes for a particular video.
Its similar to the YouTube system where you can voteUp or voteDown a particular video.
Each vote involves adding a row to the video.votes table, which logs the time, vote direction(up or down), the client IPaddress( using PHP: $ip = $_SERVER[‘REMOTE_ADDR’]; ), and of course the ID of the video in question.
Adding votes is as simple as; (pseudocode): Javascript:onClick( vote( a,b,c,d ) ), which passes variables to PHP insertion script via ajax, and finally we replace the voteing buttons with a “Thank You For Voting” message.
THE PROBLEM:
If you reload/refresh the page after voting, you can vote again, and again, and again, you get the point.
MY QUESTION:
How do you limit the amount of times a particular user votes for a particular video??
MY THOUGHTS:
Do you use cookies, and add a new cookie with the id of the video. And check for a cookie before you insert a new vote.?
OR
Before you insert the vote, do you use the IPaddress and the videoID to see if this same user(IP) has voted for this same video(vidID) in the past 24hrs(mktime), and either allow or dissallow the voteInsertion based on this query?
OR
Do you just not care? Take the assumption that most users are sane, and have better things to do than refresh pages and vote repeatedly.??
Any suggestions or ideas welcome.
Cookies can be easily disabled or very quickly cleared. Saving a vote to a cookie is unreliable and votes could be gamed with no problem.
Many users could be using the same router, effectively having the same IP. By doing this, you could be irritating users by stopping them from voting because another person from the same office/household has already voted on the video before sending them the link.
This is entirely subjective and dependant on the importance of the votes. If voting is an important part of the site, it’s best to care as much as you possibly can. For instance, if videos were sorted on highest rated, some users could vote many times to increase the popularity of their personal/favourite video, giving the impression of popularity to attract more views.
Where voting is important, it’s best to only allow registered users to vote. Sure, people can and will make multiple accounts to vote (see http://gallery.live.com for an example), but you’re making it a lot harder for them. If voting is not really important I would go with the cookie option.