I am creating a session for a login logout system. But my session_destroy isn’t working. The session variable is still there once I click logout.
Here’s how I create my session.
session_start();
$username = $_GET['username'];
$_SESSION["username"] = $username;
header('Location: employeepage.php');
Then here’s how I recieve it.
session_destroy();
header('Location: login.php');
When I click logout using jquery. I redirect to a page where the session should be destroyed.
$('#logoutbtn').live("click",function(){
window.location.replace("logout.php");
});
And here is how I destroy it.
session_destroy();
header('Location: login.php');
Any ideas?
You also neee to call
session_start()before usingsession_destroy.From the manual: