Skip to content
Snippets Groups Projects
Commit 2bda5c9b authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #1677 from greezybacon/issue/session-expire


Session never expires

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents f87318be fc5480f9
No related branches found
No related tags found
No related merge requests found
...@@ -69,6 +69,23 @@ class osTicketSession { ...@@ -69,6 +69,23 @@ class osTicketSession {
$this->destroy($oldId); $this->destroy($oldId);
} }
static function destroyCookie() {
setcookie(session_name(), 'deleted', 1,
ini_get('session.cookie_path'),
ini_get('session.cookie_domain'),
ini_get('session.cookie_secure'),
ini_get('session.cookie_httponly'));
}
static function renewCookie($baseTime=false, $window=false) {
setcookie(session_name(), session_id(),
($baseTime ?: time()) + ($window ?: SESSION_TTL),
ini_get('session.cookie_path'),
ini_get('session.cookie_domain'),
ini_get('session.cookie_secure'),
ini_get('session.cookie_httponly'));
}
function open($save_path, $session_name){ function open($save_path, $session_name){
return (true); return (true);
} }
......
...@@ -133,6 +133,8 @@ class ClientSession extends EndUser { ...@@ -133,6 +133,8 @@ class ClientSession extends EndUser {
} }
function refreshSession($force=false){ function refreshSession($force=false){
global $cfg;
$time = $this->session->getLastUpdate($this->token); $time = $this->session->getLastUpdate($this->token);
// Deadband session token updates to once / 30-seconds // Deadband session token updates to once / 30-seconds
if (!$force && time() - $time < 30) if (!$force && time() - $time < 30)
...@@ -140,6 +142,8 @@ class ClientSession extends EndUser { ...@@ -140,6 +142,8 @@ class ClientSession extends EndUser {
$this->token = $this->getSessionToken(); $this->token = $this->getSessionToken();
//TODO: separate expire time from hash?? //TODO: separate expire time from hash??
osTicketSession::renewCookie($time, $cfg->getClientSessionTimeout());
} }
function getSession() { function getSession() {
...@@ -177,12 +181,16 @@ class StaffSession extends Staff { ...@@ -177,12 +181,16 @@ class StaffSession extends Staff {
} }
function refreshSession($force=false){ function refreshSession($force=false){
global $cfg;
$time = $this->session->getLastUpdate($this->token); $time = $this->session->getLastUpdate($this->token);
// Deadband session token updates to once / 30-seconds // Deadband session token updates to once / 30-seconds
if (!$force && time() - $time < 30) if (!$force && time() - $time < 30)
return; return;
$this->token=$this->getSessionToken(); $this->token=$this->getSessionToken();
osTicketSession::renewCookie($time, $cfg->getStaffSessionTimeout());
} }
function getSession() { function getSession() {
......
...@@ -19,6 +19,7 @@ require('client.inc.php'); ...@@ -19,6 +19,7 @@ require('client.inc.php');
if ($thisclient && $_GET['auth'] && $ost->validateLinkToken($_GET['auth'])) if ($thisclient && $_GET['auth'] && $ost->validateLinkToken($_GET['auth']))
$thisclient->logOut(); $thisclient->logOut();
osTicketSession::destroyCookie();
Http::redirect('index.php'); Http::redirect('index.php');
?> ?>
...@@ -31,6 +31,8 @@ TicketLock::removeStaffLocks($thisstaff->getId()); ...@@ -31,6 +31,8 @@ TicketLock::removeStaffLocks($thisstaff->getId());
session_unset(); session_unset();
session_destroy(); session_destroy();
osTicketSession::destroyCookie();
@header('Location: login.php'); @header('Location: login.php');
require('login.php'); require('login.php');
?> ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment