startRecording('session'); $session_handler = $config->get('system', 'session_handler', self::HANDLER_DEFAULT); try { if ($mode->isInstall() || $mode->isBackend()) { $session = new Type\Memory(); } else { switch ($session_handler) { case self::HANDLER_DATABASE: $handler = new Handler\Database($dba, $logger, $server); break; case self::HANDLER_CACHE: $cache = $cacheFactory->createDistributed(); // In case we're using the db as cache driver, use the native db session, not the cache if ($config->get('system', 'cache_driver') === DatabaseCache::NAME) { $handler = new Handler\Database($dba, $logger, $server); } else { $handler = new Handler\Cache($cache, $logger); } break; default: $handler = null; } $session = new Type\Native($baseURL, $handler); } } catch (\Throwable $e) { $logger->notice('Unable to create session', ['mode' => $mode, 'session_handler' => $session_handler, 'exception' => $e]); $session = new Type\Memory(); } finally { $profiler->stopRecording(); return $session; } } }