javascriptsocial-media-like

Public votes and avoiding mutliple vote: using cookies or IP?


How do you handle public vote (anyone can "like or dislike" an article) and to restrict him to vote only one time?

Have I to use cookies? (with the problem that he can remove the cookie and vote x999 times) or I store his IP in database?


Solution

  • The solution has three parts:

    1. use a cookie to prevent double votes
    2. store all vote events in the database (ip, user agent, poll/article id, vote)
    3. implement an algorithm which will run every 24h to delete the double votes which escaped from #1. The algo will use data from #2

    Using only the IP is not appropriate as it can leave tons of people out of the voting system.