Same system this site uses for example. You can vote down or up, but your votes are persistent between logins so you cannot cast duplicate vote, only change your vote to the opposite.
How would one go implement this?
Only thing that I thought of is having an extra field in database row, that would store the IDs of users that have voted separated by common deliminator. So when user votes, he gets added to the end of the list. Something like voted{1, 45, 5} and then iterate over that array when new vote arrive and match it, if it is already in the array, do not count the vote. If it is not, add the vote and add the user ID to the field. But that spirals out of control quickly in terms of iterations on each subsequent vote.
Other thing is storing it in a cookie, but that could be circumvented by the tech savyy users. Or store it in a file and look up that file, but still, you get to iterate over the file just like if you kept it in database.
Is there any other, more elegant, way to do what I want? I tried googling for some solutions, but came empty handed.