-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathsession.php
36 lines (31 loc) · 972 Bytes
/
session.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
<?php
session_start();
if(empty($_SESSION['user_name'])) {
header('Location: login.php');
}
#point your github server endpoints here, and do NOT forget the trailing slash
$_SESSION['git_endpoint'] = array(
'internal' => 'https://github.dummycorp.com/',
'external' => 'https://github.com/'
);
$time = $_SERVER['REQUEST_TIME'];
/**
* for a 60 minute timeout, specified in seconds
*/
$timeout_duration = 60 *60;
/**
* Here we look for the user’s LAST_ACTIVITY timestamp. If
* it’s set and indicates our $timeout_duration has passed,
* blow away any previous $_SESSION data and start a new one.
*/
if (isset($_SESSION['LAST_ACTIVITY']) && ($time - $_SESSION['LAST_ACTIVITY']) > $timeout_duration) {
session_unset();
session_destroy();
session_start();
header('Location: login.php');
}
/**
* Finally, update LAST_ACTIVITY so that our timeout
* is based on it and not the user’s login time.
*/
$_SESSION['LAST_ACTIVITY'] = $time;