Module: nagvis Branch: master Commit: 2f2edbf30077a6c62f057f33e8bd9a2c6a4bca2f URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=2f2edbf30077a6c62f057f33e8bd9a2c6a4bca2f
Author: Lars Michelsen <[email protected]> Date: Sat Apr 24 19:19:06 2010 +0200 #270 The session cookie is now extended dynamically while the session itselfs ends after expiration when the browser is idle --- share/server/core/ajax_handler.php | 4 +--- share/server/core/classes/CoreAuthModSession.php | 4 +--- share/server/core/classes/CoreSessionHandler.php | 9 +++++---- share/server/core/classes/GlobalLanguage.php | 4 +--- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/share/server/core/ajax_handler.php b/share/server/core/ajax_handler.php index 89302bf..a71cdbe 100644 --- a/share/server/core/ajax_handler.php +++ b/share/server/core/ajax_handler.php @@ -54,9 +54,7 @@ try { * Session: Handle the user session */ - $SHANDLER = new CoreSessionHandler($CORE->getMainCfg()->getValue('global', 'sesscookiedomain'), - $CORE->getMainCfg()->getValue('global', 'sesscookiepath'), - $CORE->getMainCfg()->getValue('global', 'sesscookieduration')); + $SHANDLER = new CoreSessionHandler(); /* * Authentication 1: First try to use an existing session diff --git a/share/server/core/classes/CoreAuthModSession.php b/share/server/core/classes/CoreAuthModSession.php index c66ae92..79da5d9 100644 --- a/share/server/core/classes/CoreAuthModSession.php +++ b/share/server/core/classes/CoreAuthModSession.php @@ -55,9 +55,7 @@ class CoreAuthModSession extends CoreAuthModule { 'passNewPassword' => true ); - $this->SHANDLER = new CoreSessionHandler($this->CORE->getMainCfg()->getValue('global', 'sesscookiedomain'), - $this->CORE->getMainCfg()->getValue('global', 'sesscookiepath'), - $this->CORE->getMainCfg()->getValue('global', 'sesscookieduration')); + $this->SHANDLER = new CoreSessionHandler(); } private function initRealAuthModule() { diff --git a/share/server/core/classes/CoreSessionHandler.php b/share/server/core/classes/CoreSessionHandler.php index c24baa0..c3c95c2 100644 --- a/share/server/core/classes/CoreSessionHandler.php +++ b/share/server/core/classes/CoreSessionHandler.php @@ -45,7 +45,7 @@ class CoreSessionHandler { } // Set custom params for the session cookie - session_set_cookie_params($iDuration, $sPath, $sDomain); + session_set_cookie_params(0, $sPath, $sDomain); // Start a session for the user when not started yet if(!isset($_SESSION)) { @@ -59,11 +59,12 @@ class CoreSessionHandler { if(isset($_COOKIE[SESSION_NAME])) { // Don't reset the expiration time on every page load - only reset when // the half of the expiration time has passed - if(time() > $this->get('sessionExpires') - ($iDuration/2)) { - setcookie(SESSION_NAME, $_COOKIE[SESSION_NAME], time() + $iDuration, $sPath, $sDomain); + if(time() >= $this->get('sessionExpires') - ($iDuration/2)) { + $exp = time() + $iDuration; + setcookie(SESSION_NAME, $_COOKIE[SESSION_NAME], $exp, $sPath, $sDomain); // Store the update time of the session cookie - $this->set('sessionExpires', time()+$iDuration); + $this->set('sessionExpires', $exp); } } } diff --git a/share/server/core/classes/GlobalLanguage.php b/share/server/core/classes/GlobalLanguage.php index 6e45e19..a459615 100644 --- a/share/server/core/classes/GlobalLanguage.php +++ b/share/server/core/classes/GlobalLanguage.php @@ -44,9 +44,7 @@ class GlobalLanguage { $this->textDomain = $textDomain; if($this->CORE->getMainCfg() !== null) { - $this->SHANDLER = new CoreSessionHandler($this->CORE->getMainCfg()->getValue('global', 'sesscookiedomain'), - $this->CORE->getMainCfg()->getValue('global', 'sesscookiepath'), - $this->CORE->getMainCfg()->getValue('global', 'sesscookieduration')); + $this->SHANDLER = new CoreSessionHandler(); } $this->sCurrentLanguage = $this->gatherCurrentLanguage(); ------------------------------------------------------------------------------ _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
