-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogout.php
More file actions
46 lines (39 loc) · 1.19 KB
/
Copy pathlogout.php
File metadata and controls
46 lines (39 loc) · 1.19 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
<?php
/**
* Logout Script
*
* This script logs out the user by destroying the session and redirecting to the index.php page.
*
*/
// Check if a session is already started, and start a new session if not
require 'session_config.php';
require 'dbcon.php';
require_once __DIR__ . '/includes/chatbot_session.php';
// Revoke the per-session chatbot API key (if any) before tearing down the
// session, so the row gets revoked_at stamped for audit.
try {
chatbot_session_key_revoke($con);
} catch (Throwable $e) {
error_log('logout chatbot revoke error: ' . $e->getMessage());
}
// Unset all session variables
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(
session_name(),
'',
time() - 42000,
$params["path"],
$params["domain"],
$params["secure"],
$params["httponly"]
);
}
// Finally, destroy the session
session_destroy();
// Redirect to the index.php page
header("Location: index.php");
exit; // Ensure no further code is executed