-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlogout.php
34 lines (29 loc) · 978 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
31
32
33
34
<?php
require_once("includes/header.php");
function getUserIpAddr(){
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
//ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
//ip pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
$userIPAddress = getUserIpAddr();
$device = $_SERVER['HTTP_USER_AGENT'];
$query = $con->prepare("DELETE FROM active_sessions WHERE username =:un AND ipAddress=:ip;");
$query->bindValue(":un", $userLoggedIn);
$query->bindValue(":ip", $userIPAddress);
$query->execute();
session_start();
session_destroy();
if(isset($_GET["reason"]) && $_GET["reason"] == "sessnexp"){
header("Location: login.php?reason=sessnexp");
}
else {
header("Location: login.php");
}
?>