private function getSessionBag(Request $request): SessionBagInterface
    {
        if (!$request->hasSession() || null === ($session = $request->getSession())) {
            throw new \RuntimeException('The request did not contain a session.');
        }

        $name = 'contao_frontend';

        if ($this->scopeMatcher->isBackendRequest($request)) {
            $name = 'contao_backend';
        }

        return $session->getBag($name);
    }
private function getSessionBag(Request $request): SessionBagInterface
    {
        if (!$request->hasSession() || null === ($session = $request->getSession())) {
            throw new \RuntimeException('The request did not contain a session.');
        }

        $name = 'contao_frontend';

        if ($this->scopeMatcher->isBackendRequest($request)) {
            $name = 'contao_backend';
        }

        return $session->getBag($name);
    }
Returns the session bag.

@throws \RuntimeException