View Full Version : logout script

07-31-2007, 05:45 PM
For some reason I am able to run my login script which after doing so will put more options into my menu to allow me to do other things. Well one option it brings up of course is "logout". Well for some reason it doesnt logout. I dont know if you will need more info but this is my log out script, I cant seem to see where the issue is.

//this is the log-out page for the site

//include the configuration file for error management and such
require_once ('config.inc');

//set the page title and include the header
$page_title = 'Logout';
include ('header.php');

if (isset($_SESSION['first_name'])) { //if no first name variable exists, redirect the user

header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php");
ob_end_clean(); //delete the buffer
exit();//quit the script

} else { //log the user out
$_SESSION = array(); //destroy the variables
session_destroy(); //destroy the session itself
setcookie (session_name(), '', time()-300, '/', '', 0); //destroy the cookie


//print a customized message
echo "<h3>You are now logged out.</h3>";

include ('footer.php');

Thanks for the help

07-31-2007, 06:11 PM
if (isset($_SESSION['first_name'])) means that if it DOES exist. I think you need


07-31-2007, 06:18 PM
oops typo:o thanks for pointing out my blindness and the ability to type a script...lol