Welcome to WebmasterWorld Guest from 54.162.121.80
if(session_destroy())
{
header("Location: login.php");
}
Because if there's no session already, session_destroy() will give you an error...
:
This is the same concept as your initial code - "If I can execute session_destroy it means there's a session to destroy, so do it and redirect."
<?php
include ($_SERVER['DOCUMENT_ROOT'] . "/db_connect.php");
// Ther're leaving, update their last online time etc
$member_ID = $_SESSION['member_ID'];
$update = "UPDATE members_log";
$update.= " SET log_lastonline = log_activecheck,";
$update.= " log_isonline = 'n'";
$update.= " WHERE log_mem_ID = '$member_ID'";
mysql_query($update);
// LOG OUT
session_start();
unset($_SESSION['login_user']);
header("Location: http://www.website.com/bye.php");
?>
...the original script I got had literaly 'session start() - if(session destroy)
...when I came to adjust the logout script I got confiused by this and had to ask!