0
Hello!
In my php file I have the code
page php.
session_start();
$valor = isset($_SESSION['usuario']) ? 'S' : 'N';
if($valor == 'N'){
header('location: .');
}
echo "Sesssao: ".$valor;
to exit, in another file I do by clicking on the exit link that calls this function
function sair(){
session_destroy();
unset($_SESSION['usuario']);
$_SESSION['usuario'] = null;
header('location: .');
session_commit();
}
But when I access the direct page that checks the session, without going through the login he said that there is always session is whether it has the word session_start();
Where is this function
sair()
? She’s in the same file as thepage.php
?– Vanildo Souto Mangueira
on another page I call the function
– adventistaam
The instruction
session_start()
should be on all session handling pages. The question is when you run thesession_destroy
, he does not understand which session to delete. Adds the instructionsession_start()
before destroying. It is best to put thesession_start()
in index.php or the first script that will always be run.– Vanildo Souto Mangueira
On the index you already have session_start
– adventistaam
It worked! That’s right! I put the
session_start()
before thesession_destroy()
– adventistaam