-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogout.php
More file actions
32 lines (22 loc) · 861 Bytes
/
logout.php
File metadata and controls
32 lines (22 loc) · 861 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
32
<?php // This page lets the user logout.
// If no session value is present, redirect the user:
session_start(); // Accessing the existing session.
if (!isset($_SESSION['user_id'])) {
// Need the functions to create an absolute URL:
require_once ('includes/login_functions.inc.php');
$url = absolute_url();
header("Location: $url");
exit(); // Quit the script.
} else { // Cancel the session.
$_SESSION = array(); // 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 PHP header:
$page_title = 'Logged Out!';
include ('includes/header.php');
// Print a customized message:
echo "<h1>Logged Out!</h1>
<form><p><label>You are now logged out!</label></p></form>";
include ('includes/footer_login.php');
?>