Jump to content
Larry Ullman's Book Forums

Can I Use Cookie In A Poll Script To Avoid Multiple Voting?


Recommended Posts

I'm trying to make a poll script, where users can select an answer for a particular question. How to avoid multiple answers from the same user?

I tried to set a cookie in the questions.php page which displays questions and answers. Then trying to access that cookie in submitanswer.php page, to run it if(!isset($_COOKIE['poll']) { // update the answer counting. } else { echo "only one answer" }.

 

But this is not working. The cookie is always set as it is coming from the previous page, in this scenario. How can a cookie be helpful here? Or is there anything else I need to know/do?

thanks

Link to comment
Share on other sites

if you have it setup where the person has to be logged in then create a table in mysql that logs there userid and the poll id then if it exists give the error that they already answered the poll if not you can log there ip address instead of a userid, when using cookies they can easily delete it and poll again atleat with a database they can't

  • Upvote 3
Link to comment
Share on other sites

 Share

×
×
  • Create New...