krz/vox-populi
clone: git clone https://gitbay.org/krz/vox-populi.git
main: logout.php · raw
1<?php
2
3// Initialize the session.
4// If you are using session_name("something"), don't forget it now!
5session_start();
6
7// Delete authentication cookies
8unset($_COOKIE["perm_token"]);
9setcookie("perm_token", "", time() - 3600, "/vox-populi/dashboard");
10unset($_COOKIE["perm_secret"]);
11setcookie("perm_secret", "", time() - 3600, "/vox-populi/dashboard");
12unset($_COOKIE["PHPSESSID"]);
13setcookie("PHPSESSID", "", time() - 3600, "/vox-populi/dashboard");
14
15// Unset all of the session variables.
16$_SESSION = array();
17unset($_SESSION['perm_token']);
18unset($_SESSION['perm_secret']);
19session_unset();
20
21// If it's desired to kill the session, also delete the session cookie.
22// Note: This will destroy the session, and not just the session data!
23if (ini_get("session.use_cookies")) {
24 $params = session_get_cookie_params();
25 setcookie(session_name(), '', time() - 42000,
26 $params["path"], $params["domain"],
27 $params["secure"], $params["httponly"]
28 );
29}
30
31// Finally, destroy the session.
32session_destroy();
33session_write_close();
34
35// Go back to sign-in page
36header('Location: https://example.com/vox-populi/');
37die();
38
39?>