-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogout.php
More file actions
48 lines (37 loc) · 1.5 KB
/
logout.php
File metadata and controls
48 lines (37 loc) · 1.5 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/////////////////////////////////////////////////////////////////////
//
// Written by Jim Garbe-- Dynamic Checksheet
//
/////////////////////////////////////////////////////////////////////
// If the user is logged in, delete the session vars to log them out
//session_save_path('/home/user/...'); // If an alternative session location is needed on the server.
// if(isset($PHPSESSID)) {
$message = "<p>End of session ($PHPSESSID).";
session_start( );
session_destroy( );
setcookie("PHPSESSID","",time()-3600,"/"); // delete session cookie
// } else {
// $message = "<p>There was no session to destroy!";
// }
// If the user is logged in, delete the session vars to log them out
//session_start();
// if (isset($_SESSION['user_id'])) {
// Delete the session cookie by setting its expiration to an hour ago (3600)
// if (isset($_COOKIE[session_name()])) {
// setcookie(session_name(), '', time() - 3600);
// }
// Delete the session vars by clearing the $_SESSION array
// $_SESSION = array();
// Destroy the session
// session_destroy();
// }
// Delete the user ID and username cookies by setting their expirations to an hour ago (3600)
// setcookie('PHPSESSID','',time() - 3600);
setcookie('user_id', '', time() - 3600);
setcookie('username', '', time() - 3600);
setcookie('status', '', time() - 3600);
// Redirect to the home page
$home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/index.php';
header('Location: ' . $home_url);
?>