diff --git a/library/Icinga/Session/PhpSession.php b/library/Icinga/Session/PhpSession.php index d3b08bd14..52bbc0efe 100644 --- a/library/Icinga/Session/PhpSession.php +++ b/library/Icinga/Session/PhpSession.php @@ -45,6 +45,13 @@ class PhpSession extends Session */ const NAMESPACE_PREFIX = 'ns.'; + /** + * Whether the session has already been closed + * + * @var bool + */ + private $hasBeenTouched = false; + /** * Name of the session * @@ -110,7 +117,21 @@ class PhpSession extends Session private function open() { session_name($this->sessionName); + + if ($this->hasBeenTouched) { + $cacheLimiter = ini_get('session.cache_limiter'); + ini_set('session.use_cookies', false); + ini_set('session.use_only_cookies', false); + ini_set('session.cache_limiter', null); + } + session_start(); + + if ($this->hasBeenTouched) { + ini_set('session.use_cookies', true); + ini_set('session.use_only_cookies', true); + ini_set('session.cache_limiter', $cacheLimiter); + } } /** @@ -131,6 +152,7 @@ class PhpSession extends Session } session_write_close(); + $this->hasBeenTouched = true; } /** @@ -148,6 +170,7 @@ class PhpSession extends Session } session_write_close(); + $this->hasBeenTouched = true; } /** @@ -161,6 +184,7 @@ class PhpSession extends Session session_destroy(); $this->clearCookies(); session_write_close(); + $this->hasBeenTouched = true; } /**