function logout() { /** * Delete cookies - the time must be in the past, * so just negate what you added when creating the * cookie. */ if (isset($_COOKIE['cookname']) && isset($_COOKIE['cookfn'])) { setcookie("cookname", "", time() - COOKIE_EXPIRE, COOKIE_PATH); setcookie("cookfn", "", time() - COOKIE_EXPIRE, COOKIE_PATH); } /* Unset PHP session variables */ unset($_SESSION['username']); unset($_SESSION['firstname']); /* Reflect fact that user has logged out */ $logged_in = false; /** * Remove from active users table and add to * active guests tables. */ removeActiveUser($username); addActiveGuest($_SERVER['REMOTE_ADDR'], $time); /* Set user level to guest */ $username = GUEST_NAME; $userlevel = GUEST_LEVEL; }
<?php include 'session.php'; $redirect = $_GET["redirect"]; if (!$redirect) { $redirect = "/"; } //session_start(); removeActiveUser($_SESSION['username']); session_destroy(); header("Location: " . $redirect);