I am trying to create a like button next to a user comment the problem is a malicious user could spam the button and it would query the database many time for validity, this is a problem. I thought about implementing a time-stamp check using CodeIgniter's Sessions but it is not working correctly. Example:
if ($this->session->userdata('last_activity') + 30 < time())
echo 'ok';
else
echo 'NOT ok';
The 'like' button uses AJAX, any ideas on how to prevent spam on the server side?