-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf_inactivity.php
39 lines (32 loc) · 1.08 KB
/
f_inactivity.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
<?php
function checkInactivity() {
define('timeout', 10); // numero di minuti passati i quali non si e' piu' attivi
$t = time();
$diff = 0;
$new = false;
if( isset($_SESSION['265353_time']) ) {
$t0 = $_SESSION['265353_time'];
$diff = $t - $t0;
} else {
$new = true;
}
if( $new == true ) {
$_SESSION['265353_time'] = time();
}
else if( $diff > 60*timeout) {
$_SESSION = array();
if( ini_get("session.use_cookies") ) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time()-3600*24, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
}
session_destroy();
$redirect="index.php";
$msg="Timeout 2min has exiperd: you need to re-do your login!";
header('Location: '.$redirect.'?msg='.$msg);
exit();
}
else {
$_SESSION['265353_time'] = time();
}
}
?>