I am using a special wrapper class around session_start() function to add protections on my sessions.
To log the user out, I have a button like this:
<a href="logout.php">
<button data-toggle="modal" data-backdrop="false" href="" name="out" class="btn btn-primary navbar-btn" style="margin-right: 3px"><span class="glyphicon glyphicon-user"></span>Log Out</button></a>
Here is the logout.php:
<?php
error_reporting(0);
include('SessionManager.php');
$mySess = new SessionManager();
$session = $mySess -> sessionStart('InstallationName'); // create/start a new session or start the existent session
$mySess -> destroy(); //destroy the session
header('Location: page1bis.php');
exit();
?>
Here is the destroy() function in my SessionManager Class:
<?php
class SessionManager
{
.
.
.
static protected function destroy()
{
echo $_SESSION['cook'];echo "<br>";
echo "hello !";
session_destroy();
echo $_SESSION['cook'];
}
}
?>
But when one click on the logout button, it goes to the lougout.php page, but no redirection is made, also here is the output of the lougout.php page:
tfe0eccar02k3pgi5b7i8i2ek5
hello !
p.s: The echos in the logout.php are just here to show that the session is effectively destroy (or there should to 2 tokens), also even if I remove them there is still the same problem