检查用户是否单击了按钮

What I would like to do is essentially check whether or not a user has clicked a certain link on a page. The idea behind the functionality is that a user can click "Thanks!" on a post created on the website, but they can only submit one "Thanks!" per post.

I have no problem creating a simple click counter for the "Thanks!" button, and save the count to a database using PDO, but I am not sure how I can assign a click to the user who's session is active.Also, posts are constantly being added to the site, so I would need a system which would scale to more posts automatically.

Any guidance is appreciated, thanks!

Note: I know I have not put any example code, but I believe this is simple enough for a good programmer to grasp quickly.

EDIT On further thought, the IP can not be used to distinguish users, as this website will be used by many people on the same IP.

Are the users logged in or anonymous? If they are logged in just save their user id in a session variable and upload it with their vote to a table in your database.

I do something similar using an Ajax request to a .php page that inserts a row with the session user ID and the vote.

If they are anonymous you can save their ip but that leads to problems with users who share the same ip address. Another (bad) option is to use cookies but users can obviously just clear their cookies and vote again.