-
Notifications
You must be signed in to change notification settings - Fork 0
/
cookies.php
45 lines (44 loc) · 1.16 KB
/
cookies.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
35
36
37
38
39
40
41
42
43
44
45
<?php
function checkCookies(){
if (isset($_COOKIE["curUser"])) {
$curUser = explode(',', $_COOKIE["curUser"]);
return $curUser;
} else {
echo '<script type="text/javascript">',
'expireMsg();',
'</script>';
}
}
function resetCookies(){
if (isset($_COOKIE["curUser"])) {
echo '<script type="text/javascript">',
'logoutMsg();',
'</script>';
}
}
?>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>;
<script type="text/javascript">
function expireMsg() {
Swal.fire({
type: 'warning',
title: 'Session Expired',
text: "Please login again",
showConfirmButton: false,
timer: 1500
}).then((result) => {
window.location.href = "/login.php";
})
}
function logoutMsg() {
Swal.fire({
type: 'success',
title: 'Logout Succesfully',
text: "See you again!",
showConfirmButton: false,
timer: 1500
}).then((result) => {
document.cookie = "curUser= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
})
}
</script>