You are here

public function CookieMonster::meWantCookie in Bakery Single Sign-On System 8.2

Adds a query parameter to check successful log in redirect URL.

Parameters

\Symfony\Component\HttpKernel\Event\ResponseEvent $event: The Event to process.

File

src/EventSubscriber/CookieMonster.php, line 82

Class

CookieMonster
C is for cookie, its good enough for me.

Namespace

Drupal\bakery\EventSubscriber

Code

public function meWantCookie(ResponseEvent $event) {
  $response = $event
    ->getResponse();
  $this->cookieJar
    ->all();
  if ($this->cookieJar
    ->count()) {
    foreach ($this->cookieJar
      ->all() as $name => $cookie) {
      if (empty($cookie)) {
        $response->headers
          ->clearCookie($name, '/', '', $this->secure);
        $response->headers
          ->clearCookie($name, '/', $this->domain, $this->secure);
      }
      else {
        $response->headers
          ->setCookie(Cookie::create($name, $cookie, $this->time
          ->getRequestTime() + $this->freshness, '/', $this->domain, $this->secure));
      }
    }
  }
}