I have a web poll that I would like my visitors to only take once. I think I understand the logic but don't know where to start with the code. Here is what I am thinking:

  1. User clicks on a link to get to the form
  2. A cookie is set on the users computer
  3. User takes the poll
  4. If users try to come back again and take the poll a second time
  5. The cookie checks against itself so see if the visitors already came
  6. Print out some sort of message like "Um, sorry but you can only take this poll once"
  7. Web poll doesn't display again.

My JS is a little rusty but I can follow along. The part I'm getting stumped on is setting the cookie and having it check itself.

P.S. Or if there is a better way, please let me know

8 Years
Discussion Span
Last Post by ~s.o.s~

If this poll is for registered users only, a better way would be to handle the voting part at the server side wherein an entry would be placed in the database against the users' name and be checked for each vote request so that he can vote only once.

If this poll is for all users of your site, cookies seem to be your best bet; though beware that if cookies / javascript are disabled, it can cause serious statistical issues. One way to avoid this would be to make the 'Post a Poll' button Javascript enabled and do a check whether cookies are enabled which disables the post a poll option for users who have javascript / cookies turned off.

BTW, all you need to know about browser cookies.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.