Search code examples
phprating

Prevent multiple votes from anonymous users in PHP


On my website I have some posts with a simple system of rating (like and don't like). Everyone should be able to rate without logging in. I am looking for a system to prevent multiple votes. I know that there isn't really a way secure way to track user however this is my idea: using cookies and then, to prevent multiple votes if a user clears the cookies, check the IP address (I will block rate from an IP only in case of multiple rates from the same in with no cookies on the PC).

Do you think it can work? I don't think any hacker will attack my website, furthermore it doesn't really matter if a user rate a post one, two or five times: I just want to prevent kind of bot and votes in order of hundreds or thousands. So I don't need the system to be so precise. What would you suggest?


Solution

  • Use cookies, IP address check and localStorage check.

    It's the best you can do.