Hello, I have a problem, with photo voting. I have an photo album and every photo have a voting pole (+ or -). I want that a user can vote a photo only one tine in an hour. I know that can be done with cookies but i don't know how. setcookie("votecookie", "imageID", time()+3600); this is working but only for a single photo. I need to create an array to store all votes. Anyone knows how? Thank you for your help.
There are 2 ways of solving this. 1. Check the IP address from previous vote on imageID and if vote is less then 3600 UNIX_TIMESTAMP seconds before current time, don't add vote and give error. 2. create a cookie named like this votecookieIMAGEID setcookie("votecookie" . imageID, "checked", time()+3600); Code (markup):
And for every vote it will be created a different cookie? it is not possible to create a cookie with all votes?
then you need to save an array to the cookie (SERIALIZE) but if you want real security i would not go for the cookie but the IP address
IP addresses can be switched via dynamic IPs or proxies. Cookies can be deleted. If you absolutely don't want vote spamming to happen, you could make user registration. If it doesn't bother you that much, I would just use the IP method.