I'm just looking to create a cookie which stores the number of correct answers someone gives in a quiz and then increment it for every correct answer.
if(isset($_GET['first'])){setcookie("answers", 0, time()+900);}
elseif($_POST['1']){
if($_POST['1']=='y'){
$_COOKIE['answers']++;
}
The first part just sets the cookie initially if they are starting the quiz. After they answer, they will move to the next page (which is the same page but with different HTML) which also has a question named "1".
The problem is, the cookie keeps getting reset to 0 at the start of every page. However, I'm positive I'm not setting it again. Any help would be much appreciated! Also, I know this isn't a very robust way to create a quiz but it's an exercise.