Allow sessions to be reopened

refs #5510
This commit is contained in:
Johannes Meyer 2014-01-23 17:21:39 +01:00
parent cf778d4609
commit efa23ad422
1 changed files with 24 additions and 0 deletions

View File

@ -45,6 +45,13 @@ class PhpSession extends Session
*/ */
const NAMESPACE_PREFIX = 'ns.'; const NAMESPACE_PREFIX = 'ns.';
/**
* Whether the session has already been closed
*
* @var bool
*/
private $hasBeenTouched = false;
/** /**
* Name of the session * Name of the session
* *
@ -110,7 +117,21 @@ class PhpSession extends Session
private function open() private function open()
{ {
session_name($this->sessionName); 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(); 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(); session_write_close();
$this->hasBeenTouched = true;
} }
/** /**
@ -148,6 +170,7 @@ class PhpSession extends Session
} }
session_write_close(); session_write_close();
$this->hasBeenTouched = true;
} }
/** /**
@ -161,6 +184,7 @@ class PhpSession extends Session
session_destroy(); session_destroy();
$this->clearCookies(); $this->clearCookies();
session_write_close(); session_write_close();
$this->hasBeenTouched = true;
} }
/** /**