Module: nagvis Branch: master Commit: 1ecfb354029310ca666c451cfc2dc3b45df32093 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=1ecfb354029310ca666c451cfc2dc3b45df32093
Author: LaMi <[email protected]> Date: Mon Nov 16 21:54:57 2009 +0100 Fixed session cookie handling: When only simple hostname given (no dot in url) then the domain param is not set for the cookies; The session cookie will be renewed after the half of the expiration time, not on every page load anymore --- share/server/core/classes/CoreSessionHandler.php | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/share/server/core/classes/CoreSessionHandler.php b/share/server/core/classes/CoreSessionHandler.php index 68f32ea..c24baa0 100644 --- a/share/server/core/classes/CoreSessionHandler.php +++ b/share/server/core/classes/CoreSessionHandler.php @@ -38,17 +38,33 @@ class CoreSessionHandler { // Set the session name (used in params/cookie names) session_name(SESSION_NAME); + // Only add the domain when it is no simple hostname + // This can be easily detected searching for a dot + if(strpos($sDomain, '.') === false) { + $sDomain = null; + } + // Set custom params for the session cookie session_set_cookie_params($iDuration, $sPath, $sDomain); // Start a session for the user when not started yet if(!isset($_SESSION)) { session_start(); + + // Store the creation time of the session + $this->set('sessionExpires', time()+$iDuration); } - // Reset the expiration time upon page load + // Reset the expiration time of the session cookie if(isset($_COOKIE[SESSION_NAME])) { - setcookie(SESSION_NAME, $_COOKIE[SESSION_NAME], time() + $iDuration, $sPath, $sDomain); + // 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); + + // Store the update time of the session cookie + $this->set('sessionExpires', time()+$iDuration); + } } } ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
