diff --git a/code/HybridSessionStore.php b/code/HybridSessionStore.php index 37f9552..067555a 100644 --- a/code/HybridSessionStore.php +++ b/code/HybridSessionStore.php @@ -444,6 +444,13 @@ class HybridSessionStore extends HybridSessionStore_Base { */ protected $handlers = array(); + /** + * True if this session store has been initialised + * + * @var bool + */ + protected static $enabled = false; + /** * @param array[HybridSessionStore_Base] */ @@ -524,6 +531,11 @@ public static function init($key = null) { $instance->setKey($key); } register_sessionhandler($instance); + self::$enabled = true; + } + + public static function is_enabled() { + return self::$enabled; } } @@ -533,6 +545,8 @@ public function preRequest(SS_HTTPRequest $request, Session $session, DataModel } public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model) { - session_write_close(); + if(HybridSessionStore::is_enabled()) { + session_write_close(); + } } }