Whenever the user restarts the game I need to clear the information, so I was perfectly using the
session_destroy();
Until I needed to use
$_SESSION['email'] e $_SESSION['senha']
So the user only had access to the game page if logged in.
So now if I use the
session_destroy();
Sessions that keep the logged in user are also destroyed and it is redirected to the home page.
I tried to use
unset();
to empty only the sessions that need to be restarted, but then the system does not work properly. Sometimes I have to keep pushing the restart button several times ...
Any suggestions?
See what I'm doing:
if ($_POST['entrada'] === "ex" ) //primeiro if
{
if(isset($_SESSION['palavra']))
{
unset($_SESSION['palavra']);
}
if(isset($_SESSION['sessoes']))
{
unset($_SESSION['sessoes']);
}
if(isset($_SESSION['letra']))
{
unset($_SESSION['letra']);
}
}//fecha o primeiro if
Within this main if there are more than ten sessions to unset, I put only three to illustrate what I'm doing.
VAR DUMP no $ _SESSION: array (13) {["background"] = > string (5) "background" ["email"] = > string (25) "[email protected]" ["password"] = > string (8) "deusdeus" ["class"] = > string (7) "input" ["count"] = > int (3) ["pos"] = > int (0) ["pos_2"] = > int (2) ["error"] = > string (1) "v" ["error_1"] = > string (1) "m" ["error_2"] = > string (1) "w" ["error_3"] = > string (1) "x" ["error_4"] = > string (1) "z" ["error_5"] = > string (1) "and"}