diff options
author | robocoder <anthon.pang@gmail.com> | 2011-05-06 21:59:59 +0400 |
---|---|---|
committer | robocoder <anthon.pang@gmail.com> | 2011-05-06 21:59:59 +0400 |
commit | 3d707d345b41e737bf8905afb9c4a7b1a209510a (patch) | |
tree | 8987dda5991d880a2726e6ccc5ae28e051f429b2 /core/Session.php | |
parent | 4b61cfa7f6c20cb5cd2068ff878823f36f2d1910 (diff) |
always use local tmp/sessions folder; Zend_Session::start() fails when session.save_path = "N;/path"
git-svn-id: http://dev.piwik.org/svn/trunk@4654 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'core/Session.php')
-rw-r--r-- | core/Session.php | 48 |
1 files changed, 12 insertions, 36 deletions
diff --git a/core/Session.php b/core/Session.php index 694a9fa1f0..686a22d285 100644 --- a/core/Session.php +++ b/core/Session.php @@ -59,45 +59,21 @@ class Piwik_Session extends Zend_Session @ini_set('session.save_path', ''); } - // for "files", we want a writeable folder; - // for shared hosting, we assume the web server has been securely configured to prevent local session file hijacking - if(ini_get('session.save_handler') == 'files') + // garbage collection may disabled by default (e.g., Debian) + if(ini_get('session.gc_probability') == 0) { - $sessionPath = ini_get('session.save_path'); - if(preg_match('/^[0-9]+;(.*)/', $sessionPath, $matches)) - { - $sessionPath = $matches[1]; - } - if(ini_get('safe_mode') || ini_get('open_basedir') || empty($sessionPath) || !@is_readable($sessionPath) || !@is_writable($sessionPath)) - { - $sessionPath = PIWIK_USER_PATH . '/tmp/sessions'; - $ok = true; - - if(!is_dir($sessionPath)) - { - Piwik_Common::mkdir($sessionPath); - if(!is_dir($sessionPath)) - { - // Unable to mkdir $sessionPath - $ok = false; - } - } - else if(!@is_writable($sessionPath)) - { - // $sessionPath is not writable - $ok = false; - } + @ini_set('session.gc_probability', 1); + } - if($ok) - { - @ini_set('session.save_path', $sessionPath); + // for "files", use our own folder to prevent local session file hijacking + if(ini_get('session.save_handler') == 'files') + { + $sessionPath = PIWIK_USER_PATH . '/tmp/sessions'; + @ini_set('session.save_path', $sessionPath); - // garbage collection may disabled by default (e.g., Debian) - if(ini_get('session.gc_probability') == 0) { - @ini_set('session.gc_probability', 1); - } - } - // else rely on default setting (assuming it is configured to a writeable folder) + if(!is_dir($sessionPath)) + { + Piwik_Common::mkdir($sessionPath); } } |