src/Sulu/Bundle/AudienceTargetingBundle/EventListener/TargetGroupSubscriber.php
public function addSetCookieHeader(FilterResponseEvent $event)
    {
        if (!$this->targetGroupStore->hasChangedTargetGroup()
            || $event->getRequest()->getPathInfo() === $this->targetGroupUrl
        ) {
            return;
        }

        $response = $event->getResponse();

        $response->headers->setCookie(
            new Cookie(
                $this->targetGroupCookie,
                $this->targetGroupStore->getTargetGroupId(true),
                AudienceTargetingCacheListener::TARGET_GROUP_COOKIE_LIFETIME
            )
        );

        $response->headers->setCookie(
            new Cookie(
                $this->visitorSessionCookie,
                time()
            )
        );
    }
public function addSetCookieHeader(FilterResponseEvent $event)
    {
        if (!$this->targetGroupStore->hasChangedTargetGroup()
            || $event->getRequest()->getPathInfo() === $this->targetGroupUrl
        ) {
            return;
        }

        $response = $event->getResponse();

        $response->headers->setCookie(
            new Cookie(
                $this->targetGroupCookie,
                $this->targetGroupStore->getTargetGroupId(true),
                AudienceTargetingCacheListener::TARGET_GROUP_COOKIE_LIFETIME
            )
        );

        $response->headers->setCookie(
            new Cookie(
                $this->visitorSessionCookie,
                time()
            )
        );
    }
public function addSetCookieHeader ( FilterResponseEvent $ event ) { if ( ! $ this -> targetGroupStore -> hasChangedTargetGroup ( ) || $ event -> getRequest ( ) -> getPathInfo ( ) === $ this -> targetGroupUrl ) { return ; } $ response = $ event -> getResponse ( ) ; $ response -> headers -> setCookie ( new Cookie ( $ this -> targetGroupCookie , $ this -> targetGroupStore -> getTargetGroupId ( true ) , AudienceTargetingCacheListener :: TARGET_GROUP_COOKIE_LIFETIME ) ) ; $ response -> headers -> setCookie ( new Cookie ( $ this -> visitorSessionCookie , time ( ) ) ) ; }
Adds the SetCookie header for the target group, if the user context has changed. In addition to that a second
cookie without a lifetime is set, whose expiration marks a new session.

@param FilterResponseEvent $event
Adds the SetCookie header for the target group if the user context has changed . In addition to that a second cookie without a lifetime is set whose expiration marks a new session .