Hey
I’m trying to write a fairly basic cookie function that allows a user to vote in a poll only once (provided they haven’t disabled cookies). Once they’ve voted, there is code on the results page that sets a cookie (which appears to be working). If they then went back to the vote page in theory they would be redirected straight to the results page rather than having the opportunity to vote again.
The code I’ve written is:
//vote page
<?php
if ($_COOKIE[“scpvotecheese”]==1) {//if cooie exists on user’s computer
header (“location:
exit; //and don’t implement the remaining code on this page
} else { //else open the voting form
?>
//html displaying the form
<?php
}
?>
//results page
<?php
setcookie(“scpvotecheese”, “1”,time()+60*60
?>
I’d be really grateful if anyone’s got any ideas as to how to make this work!
Cheers
Sara