You are here

public function TestSessionListener::onKernelResponse in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/EventListener/TestSessionListener.php \Symfony\Component\HttpKernel\EventListener\TestSessionListener::onKernelResponse()

Checks if session was initialized and saves if current request is master Runs on 'kernel.response' in test environment.

Parameters

FilterResponseEvent $event:

File

vendor/symfony/http-kernel/EventListener/TestSessionListener.php, line 55

Class

TestSessionListener
TestSessionListener.

Namespace

Symfony\Component\HttpKernel\EventListener

Code

public function onKernelResponse(FilterResponseEvent $event) {
  if (!$event
    ->isMasterRequest()) {
    return;
  }
  $session = $event
    ->getRequest()
    ->getSession();
  if ($session && $session
    ->isStarted()) {
    $session
      ->save();
    $params = session_get_cookie_params();
    $event
      ->getResponse()->headers
      ->setCookie(new Cookie($session
      ->getName(), $session
      ->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']));
  }
}