-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
30 lines (24 loc) · 1.03 KB
/
config.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
<?php
// *************************************************************
// file: config.php
// created by: Alex Gordon, Elliott Staude
// date: 04-6-2014
// purpose: Config.php expires the session after a certain amount of time. It’s just an auto logout feature to make sure you don’t stay logged in for weeks at a time.
//
// *************************************************************
session_start();
// this will check for inactivity period. The second number is in seconds
define('SESSION_EXPIRE',21600);
// check passage of time, force log-out session expire time after time set above
if(isset($_SESSION['last_activity']) && (time() - strtotime($_SESSION['last_activity']) > SESSION_EXPIRE)) {
// destroy session
session_unset();
session_destroy();
}
// every time the user performs an action, we need to reset the expiration time
// so if a user is logged in and unexpired, update activity
if(isset($_SESSION['user'])) {
// user has been logged in for this long
$_SESSION['last_activity'] = date('Y-m-d H:i:s');
}
?>