forked from nozomu-y/kleines-mypage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logout.php
30 lines (27 loc) · 855 Bytes
/
logout.php
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
<?php
session_start();
// logout the user who accessed logout.php
if (isset($_POST['logout'])) {
$_SESSION = array();
setcookie(session_name(), '', time() - 1, '/');
session_destroy();
require __DIR__.'/Common/dbconnect.php';
if (!empty($_COOKIE['mypage_auto_login'])) {
$token = $_COOKIE['mypage_auto_login'];
// delete token from database
$query = "DELETE FROM auto_login WHERE token = '$token'";
$result = $mysqli->query($query);
if (!$result) {
print("Query Failed : " . $mysqli->error);
$mysqli->close();
exit();
}
// delete token from browser cookie
setcookie("mypage_auto_login", "", time() - 60);
}
header("Location: ".MYPAGE_ROOT."/login/");
exit();
} else {
header("Location: ".MYPAGE_ROOT);
exit();
}