I have some variable where everytime the form is submiited or page is refreshed, it adds 1 to $sessionMinus. But if the user goes onto the previous page and then goes back onto this page, I want $sessionMinus to go back to being ‘1’.
At the moment if lets say the number is 3 and then the user goes back to previous page and then back to this page, it still displays 3, but I want it to go back to 1. I heard I have to set either $sessionMinus or $_SESSION[‘sessionCount’] to ‘1’ on the previous page but how do I do this?
below is the code for the current page (not previous page) on how the $sessionMinus is declared and incremented:
if(!isset($_SESSION['sessionCount'])){
$_SESSION['sessionCount'] = 1;
}
else
{
$_SESSION['sessionCount']++;
}
$sessionMinus = $_SESSION['sessionCount'];
?>
On the previous page, do: