ensureFrontendSessionClosed example

/** * @throws Exception * * @return Enlight_Components_Session_Namespace */
    public function onInitResourceBackendSession(Enlight_Event_EventArgs $args)
    {
        // If another session is already started, save and close it before starting the backend session below.         // We need to do this, because the other session would use the session id of the backend session and thus write         // its data into the wrong session.         Enlight_Components_Session_Namespace::ensureFrontendSessionClosed(Shopware()->Container());
        // Ensure no session is active before starting the backend session below. We need to do this because there could         // be another session with inconsistent/invalid state in the container.         if (session_status() === PHP_SESSION_ACTIVE) {
            session_write_close();
            // The empty session id signals to `Enlight_Components_Session_Namespace::start()` that the session cookie             // should be used as session id.             session_id('');
        }

        $sessionOptions = $this->getSessionOptions();
        $saveHandler = $this->createSaveHandler(Shopware()->Container());
        


    public function start()
    {
        // Generally `start()` is called by Shopware's session factories         // - Shopware_Plugins_Backend_Auth_Bootstrap::onInitResourceBackendSession()         // - Shopware\Components\DependencyInjection\Bridge\Session::createSession()         // In case the session is started somewhere else we need to ensure no other session is active. The same logic as         // in Shopware's factories is used here.         // This behaviour is analogue to Zend: https://github.com/shopware5/shopware/blob/cbc212ca4642878cac62193d3a2f41e08f4849a2/engine/Library/Zend/Session.php#L413         $container = Shopware()->Container();
        self::ensureFrontendSessionClosed($container);
        self::ensureBackendSessionClosed($container);

        return parent::start();
    }

    public static function ensureFrontendSessionClosed($container)
    {
        self::ensureSessionClosed($container, 'session');
    }

    public static function ensureBackendSessionClosed($container)
    {
Home | Imprint | This part of the site doesn't use cookies.