hi everone
i have a CMS database system in which members can log in and log out.
The log- in works perfectly. However, i am having problems with the log out script. Although the script works and does indeed log user out, it does however causes a server error.
i noticed the server error when i did a 'broken links check' on the site. The log out script causes the server error which inturn causes broken links on every page of the site. This is obviously unacceptable.
Am i doing anything wrong. i have enclose a copy of the script.
i am enlose below a copy of the script.
$page_title = 'Logout';
// If no first_name session variable exists, redirect the user:
if (!isset($_SESSION['first_name'])) {
require_once ('config.php');
$url = BASE_URL . 'index.php'; // Define the URL.
ob_end_clean(); // Delete the buffer.
header("Location: $url");
exit(); // Quit the script.
echo '<h3 class="logout" >You are not logged in</h3>';
} elseif (isset($_SESSION['first_name']))
{ Log out the user.
require_once ('config.php');
$_SESSION = array(); // Destroy the variables.
session_destroy(); // Destroy the session itself.
setcookie (session_name(), '', time()-300); // Destroy the cookie.
echo '<h3 class= "logout" >You are now logged out.</h3>';
}
thank you for your kind help.
warm regards
Andreea