Skip to content

Commit

Permalink
Fix for Session Fixation and Session expire #99
Browse files Browse the repository at this point in the history
  • Loading branch information
BSteelooper committed Apr 29, 2021
1 parent dde5ac2 commit 33a6792
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions admin.php
Expand Up @@ -27,6 +27,7 @@
//Include variables.
require_once ('data/inc/variables.all.php');


//First check if we've installed pluck.
if (!file_exists('data/settings/install.dat')) {
$titelkop = $lang['install']['not'];
Expand All @@ -36,12 +37,32 @@
include_once ('data/inc/footer.php');
exit;
}

//If pluck has been installed, proceed.
else {
require_once ('data/settings/token.php');

//implement session expiration issue #99
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 7200)) {
// last request was more than 2 hours ago
unset($_SESSION[$token]);
unset($token);
session_unset(); // unset $_SESSION variable for the run-time
session_destroy(); // destroy session data in storage
redirect('login.php', 0);
exit;
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp

// prevent session fixation issue #99
if (!isset($_SESSION['CREATED'])) {
$_SESSION['CREATED'] = time();
} else if (time() - $_SESSION['CREATED'] > 1800) {
// session started more than 30 minutes ago
session_regenerate_id(true); // change session ID for the current session and invalidate old session ID
$_SESSION['CREATED'] = time(); // update creation time
}

//Then check if we are properly logged in.
require_once ('data/settings/token.php');
if (!isset($_SESSION[$token]) || ($_SESSION[$token] != 'pluck_loggedin')) {
$_SESSION['pluck_before'] = 'admin.php?'.$_SERVER['QUERY_STRING'];
$titelkop = $lang['login']['not'];
Expand Down

0 comments on commit 33a6792

Please sign in to comment.