-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogout.php
More file actions
31 lines (23 loc) · 843 Bytes
/
logout.php
File metadata and controls
31 lines (23 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php # Script 12.11 - logout.php #2
// This page lets the user logout.
// This version uses sessions.
session_start(); // Access the existing session.
// If no session variable exists, redirect the user:
if (!isset($_SESSION['dealer_name'])) {
// Need the functions:
require('includes/login_functions.inc.php');
redirect_user();
} else { // Cancel the session:
$dealer_name = $_SESSION['dealer_name'];
$_SESSION = []; // Clear the variables.
session_destroy(); // Destroy the session itself.
setcookie('PHPSESSID', '', time()-3600, '/', '', 0, 0); // Destroy the cookie.
}
// Set the page title and include the HTML header:
$page_title = 'Logged Out!';
include('includes/header.html');
// Print a customized message:
echo "<h1>Logged Out!</h1>
<p>You are now logged out {$dealer_name}!</p>";
include('includes/footer.html');
?>