Here is what I use:
<?php
create mechanism to destroy session
// check if user is logged in
if (!isset($SESSION['first_name'])) {
include ('templates/header.inc');
echo 'You aren\'t logged in';
exit();
} else { // log the user out
$SESSION = array(); // destroy session variables
session_destroy(); // destroy session
setcookie ('PHPSESSID', '', time() -300, '/', '', 0); // destroy cookie
include ('templates/header.inc');
echo '<p8>You have been successfully logged out</p8>';
}
?>
it sets the variables in the session to NULL and deletes the cookie