diff options
author | robocoder <anthon.pang@gmail.com> | 2011-08-01 00:28:45 +0400 |
---|---|---|
committer | robocoder <anthon.pang@gmail.com> | 2011-08-01 00:28:45 +0400 |
commit | c20ca2a38dd13a827717fd3de2904281b0bd26f4 (patch) | |
tree | bb1f84484d3c3e1b75c46b1e6ad07e2eafd0b72b /core/Session.php | |
parent | adc090e386c9cbc311e401b0c01e5c5f661cabd0 (diff) |
refs #2602 - always start the session for file-based sessions; for non-file-based sessions (e.g., dbtable), we assume there won't be an issue with too few mysql client connections
git-svn-id: http://dev.piwik.org/svn/trunk@5064 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'core/Session.php')
-rw-r--r-- | core/Session.php | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/core/Session.php b/core/Session.php index bfadc4d3b6..6f5b0b01bd 100644 --- a/core/Session.php +++ b/core/Session.php @@ -18,12 +18,34 @@ */ class Piwik_Session extends Zend_Session { + protected static $sessionStarted = false; + + /** + * Are we using file-based session store? + * + * @return bool True if file-based; false otherwise + */ + public static function isFileBasedSessions() + { + $config = Zend_Registry::get('config'); + return !isset($config->General->session_save_handler) + || $config->General->session_save_handler === 'files'; + } + + /** + * Start the session + * + * @param array $options An array of configuration options; the auto-start (bool) setting is ignored + */ public static function start($options = false) { - if(Piwik_Common::isPhpCliMode()) + if(Piwik_Common::isPhpCliMode() + || self::$sessionStarted + || (defined('PIWIK_ENABLE_SESSION_START') && !PIWIK_ENABLE_SESSION_START)) { return; } + self::$sessionStarted = true; // use cookies to store session id on the client side @ini_set('session.use_cookies', '1'); @@ -49,10 +71,9 @@ class Piwik_Session extends Zend_Session @ini_set('session.referer_check', ''); $currentSaveHandler = ini_get('session.save_handler'); - $config = Zend_Registry::get('config'); - if (!isset($config->General->session_save_handler) - || $config->General->session_save_handler === 'files') + + if (self::isFileBasedSessions()) { // Note: this handler doesn't work well in load-balanced environments and may have a concurrency issue with locked session files |