Skip to content

Commit a2d5721

Browse files
author
Marius Cramer
committed
Set session cookie lifetime depending on timeout value set
1 parent c951bbf commit a2d5721

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

interface/lib/app.inc.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,13 @@ public function __construct() {
6565
//* Start the session
6666
if($this->_conf['start_session'] == true) {
6767

68-
$this->uses('session,ini_parser');
69-
$tmp = $this->db->queryOneRecord("SELECT value FROM sys_config WHERE config_id = 2 AND group = 'interface' AND name = 'session_timeout'");
68+
$this->uses('session');
69+
$tmp = $this->db->queryOneRecord("SELECT `value` FROM sys_config WHERE `config_id` = 2 AND `group` = 'interface' AND `name` = 'session_timeout'");
7070
if($tmp && $tmp['value'] > 0) {
7171
$this->session->set_timeout($tmp['value']);
72+
session_set_cookie_params(($tmp['value'] * 60) + 300); // make the cookie live 5 minutes longer
73+
} else {
74+
session_set_cookie_params(0); // until browser is closed
7275
}
7376

7477
session_set_save_handler( array($this->session, 'open'),
@@ -79,7 +82,7 @@ public function __construct() {
7982
array($this->session, 'gc'));
8083

8184
session_start();
82-
85+
8386
//* Initialize session variables
8487
if(!isset($_SESSION['s']['id']) ) $_SESSION['s']['id'] = session_id();
8588
if(empty($_SESSION['s']['theme'])) $_SESSION['s']['theme'] = $conf['theme'];

0 commit comments

Comments
 (0)