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

Merge pull request #1111 from greezybacon/issue/860


session: Override PHP default for session lifetime

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 24dbf6e5 709c5975
No related branches found
No related tags found
No related merge requests found
...@@ -22,9 +22,7 @@ class osTicketSession { ...@@ -22,9 +22,7 @@ class osTicketSession {
var $id = ''; var $id = '';
function osTicketSession($ttl=0){ function osTicketSession($ttl=0){
$this->ttl =$ttl?$ttl:get_cfg_var('session.gc_maxlifetime'); $this->ttl = $ttl ?: ini_get('session.gc_maxlifetime') ?: SESSION_TTL;
if(!$this->ttl)
$this->ttl=SESSION_TTL;
// Set osTicket specific session name. // Set osTicket specific session name.
session_name('OSTSESSID'); session_name('OSTSESSID');
...@@ -32,6 +30,9 @@ class osTicketSession { ...@@ -32,6 +30,9 @@ class osTicketSession {
// Forced cleanup on shutdown // Forced cleanup on shutdown
register_shutdown_function('session_write_close'); register_shutdown_function('session_write_close');
// Set session cleanup time to match TTL
ini_set('session.gc_maxlifetime', $ttl);
if (OsticketConfig::getDBVersion()) if (OsticketConfig::getDBVersion())
return session_start(); return session_start();
...@@ -45,7 +46,7 @@ class osTicketSession { ...@@ -45,7 +46,7 @@ class osTicketSession {
// Remote port specification, as it will make an invalid domain // Remote port specification, as it will make an invalid domain
list($domain) = explode(':', $_SERVER['HTTP_HOST']); list($domain) = explode(':', $_SERVER['HTTP_HOST']);
session_set_cookie_params(86400, ROOT_PATH, $domain, session_set_cookie_params($ttl, ROOT_PATH, $domain,
osTicket::is_https()); osTicket::is_https());
//Set handlers. //Set handlers.
......
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