Script 17.11
PHP and MySQL for Dynamic Web Sites: The Forum!
English/English
You need to log in before you can be logged out!
Log in
<?php # Script 17.11 - logout.php #2 // This page lets the user logout. // This version uses sessions. // If session variable exists, delete and redirect the user back to same page if (isset($_SESSION['user_id']) && !isset($_GET['status'])) { // Need the functions: require (CHAPTER_PATH.'/'.$chapter.'/includes/17.13.php'); $_SESSION = array(); // Clear the variables. // session_unset(); deprecated session_destroy(); // Destroy the session itself. setcookie (session_name(), '', time()-3600, '/', '', 0, 0); // Destroy the session cookie. redirect_user('index.php?chapter=17&script=17.11&status=loggedout'); } else { include (CHAPTER_PATH.'/'.$chapter.'/includes/17.1.php'); // echo '<div id="content">'; if(isset($_GET['status']) && $_GET['status']=='loggedout'){ //confirm log out echo "<h1>Logged Out</h1> <p>Thanks for visiting. You are now logged out of our system.</p>"; } else { echo '<p class="error">You need to log in before you can be logged out!<br /> <a href="index.php?chapter=17&script=17.9" title="Log In">Log in</a></p>'; } // echo '</div>'; include (CHAPTER_PATH.'/'.$chapter.'/includes/17.2.php'); } ?>