I am using the following code to invalidate the session. I have linked to logout.php
in many pages. If that logout link is clicked the logout.php
page is called. The following is the code in logout.php
.
unset($_SESSION['admin']);
session_destroy();
header('Location: index.php');
Once the session is invalidated I want to open the page index.php
.
But I am geting the following error:
Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in C:\xampp\htdocs\Selection\logout.php on line 3
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\Selection\logout.php:3) in C:\xampp\htdocs\Selection\logout.php on line 4
What is wrong?