-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsession-validation.php
More file actions
42 lines (34 loc) · 1.25 KB
/
Copy pathsession-validation.php
File metadata and controls
42 lines (34 loc) · 1.25 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
<?php
/**
* Session Validation
*
* Handle Session Validation
*
* PHP version 7.2.5
*
* @category Main_App
* @package UnlockED
* @author UnlockedLabs <developers@unlockedlabs.org>
* @license https://www.gnu.org/licenses/gpl.html GPLv3
* @link http://unlockedlabs.org
*/
namespace unlockedlabs\unlocked;
session_start();
if (isset($_SESSION['last_activity']) && (time() - $_SESSION['last_activity'] > 1800)) {
// last request was more than 30 minutes ago (1800)
echo '<script>window.location="' . $_SESSION['current_site_settings']['site_url'] . '/index.php"</script>';
session_unset(); // unset $_SESSION variable for the run-time
session_destroy(); // destroy session data in storage
//echo '<script>window.location="index.php"</script>';
die();
}
if (!isset($_SESSION['username'])) {
//echo '<script>window.location="index.php"</script>';
echo '<script>window.location="' . $_SESSION['current_site_settings']['site_url'] . '/index.php"</script>';
die();
}
//echo 'session expires in<br>';
//echo date('H:i:s', time() - $_SESSION['last_activity']);
//set the current Unix timestamp in session
$_SESSION['last_activity'] = time();
//echo $_SESSION['last_activity'];