I wanna add an additional feature to my hangman game. Each time the user correctly guesses a word, their score is added by 1. However, the problem is each time the user wins they're re-directed to index.php and that resets the counter. How do I make it so that whenever it goes back to index.php, it doesn't reset but at the same time everything else does?
Depending on how you are currently resetting things, if you are unsetting the $_SESSION variable and then using it again, then I suggest changing from that, and specifically zeroing or resetting only the parts of the $_SESSION you want to change. For instance if you want to reset the guesses stored in say $_SESSION['guesses'] then just use $_SESSION['guesses'] = new array();
And then just leave your counter as it is.
Maybe if you would like to reset all except the specified one, simply store it somewhere before resetting, after that store it back to the original variable.
Instead of unset $_SESSION maybe you can use foreach loop for reseting one by one except this what you need for future.