protected function init()
{
$config = self::getConfig();
// validate that headers have not already been sent
if (headers_sent()) {
throw new SessionException('Unable to register session handler because headers have already been sent.');
}
// remove any shut down functions
session_register_shutdown();
// get the driver
$saveHandler = $config->get('Storage.Driver', '\\Webiny\\Component\\Http\\Session\\Storage\\NativeStorage');
try {
// try to create driver instance
$saveHandler = new $saveHandler($config);
// register driver as session handler
session_set_save_handler($saveHandler, false);
// start the session
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
// get session id
$this->sessionId = session_id();
// save current session locally
$this->sessionBag = $this->arr($_SESSION);
} catch (\Exception $e) {
throw new SessionException($e->getMessage());
}
}