Hello, I'm having some problems with php sessions when I start 2 sessions in the same php file.
I've been using this sample code to test:
session_name("sessao1");
session_start();
if(!isset($SESSION["param1"])){
$SESSION["param1"] = "logged";
echo "<p>abri a sessão 1 <a href=\"logout_sess1.php\">Logout</a></p>";
}
else{
echo "<p>Sessão 1 aberta <a href=\"logout_sess1.php\">Logout</a></p>";
}
session_name("sessao2");
session_start();
if(!isset($SESSION["param2"])){
$SESSION["param2"] = "logged";
echo "<p>abri a sessão 2 <a href=\"logout_sess2.php\">Logout</a></p>
<p><a href=\"sessao1.php\">Sessão 1</a></p>";
}
else{
echo "<p>Sessão 2 aberta <a href=\"logout_sess2.php\">Logout</a></p>
<p><a href=\"sessao1.php\">Sessão 1</a></p>";
}
And I have 2 php files, one for the logout of "sessao1" and another for the logout of "sessao2". The problem is when I do logout of the "sessao1", the "sessao2" is also closed, and when I do logout of the "sessao2" none of them are closed. :mad:
Any sugestion?
Here's the code of the logout:
session_name("sessao1");
session_start();
$_SESSION["param1"] = null;
session_destroy();
header("Location:sessao1.php");
the logout of the "sessao2" is the same with the exception of the 1 turns 2.