Website. VoteUp or VoteDown Videos. How to restrict users voting multiple times?
Posted
by DJDonaL3000
on Stack Overflow
See other posts from Stack Overflow
or by DJDonaL3000
Published on 2010-04-02T19:55:50Z
Indexed on
2010/04/02
20:03 UTC
Read the original article
Hit count: 221
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.
© Stack Overflow or respective owner