cookies or environment variable

  • dreamer7
  • Student
  • Student
  • dreamer7
  • Posts: 93
  • Loc: UK

Post 3+ Months Ago

Well i've come across a problem as i have made a simple vote script that saves to a .txt file and when the person votes it comes up with who they have voted and the other people that have been voted. I was thinking that there isn't actually a way of stopping them from voting once pressing back voting again and so on.. So i was wondering if there was any of you out there that can give me help on making a script that either stops their IP from voting using environment variables like REMOTE_ADDR or a script that makes cookies that last 604800ms lol (a week) any help much appreciated as always
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9128
  • Loc: Seattle, WA

Post 3+ Months Ago

You could do either cookies, IP, or both. What you would need to do if you want to prevent multiple votes by IP, is actually record all the IPs to a file and then make your script check that file each time to make sure that the person voting isn't in it. Once they vote you would need to add their ip to it.

As far as cookies, thats a whole different topic, but you would simply need to set a cookie using something like:

Code: [ Select ]
print "Set-Cookie: voted=yes;";

Then each time someone votes you would read in the cookie environment variable and check to see if they have already voted by parsing through the cookie.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 38 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.