/**
  * {@inheritdoc}
  */
 public function applyTo(ServerRequestInterface $request, ResponseInterface $response, TransportInterface $transport)
 {
     // Extend session
     if ($transport instanceof AuthenticationTransportInterface) {
         $authenticated_with = $transport->getAuthenticatedWith();
         if (!$authenticated_with instanceof SessionInterface) {
             throw new InvalidArgumentException('Only user sessions are supported');
         }
         $authenticated_with->extendSession();
         list($request, $response) = $this->cookies->set($request, $response, $this->session_cookie_name, $authenticated_with->getSessionId(), ['ttl' => $authenticated_with->getSessionTtl(), 'http_only' => true]);
         // Log in
     } elseif ($transport instanceof AuthorizationTransportInterface) {
         $authenticated_with = $transport->getAuthenticatedWith();
         if (!$authenticated_with instanceof SessionInterface) {
             throw new InvalidArgumentException('Only user sessions are supported');
         }
         list($request, $response) = $this->cookies->set($request, $response, $this->session_cookie_name, $authenticated_with->getSessionId(), ['ttl' => $authenticated_with->getSessionTtl(), 'http_only' => true]);
         // Log out or clean-up
     } elseif ($transport instanceof DeauthenticationTransportInterface || $transport instanceof CleanUpTransportInterface) {
         list($request, $response) = $this->cookies->remove($request, $response, $this->session_cookie_name);
     }
     return parent::applyTo($request, $response, $transport);
 }
Beispiel #2
0
 /**
  * Test if remove unsets prefixed cookie value.
  */
 public function testRemove()
 {
     $this->assertTrue($this->cookies->exists($this->request, 'our_cookie'));
     list($this->request, $this->response) = $this->cookies->remove($this->request, $this->response, 'our_cookie');
     $this->assertFalse($this->cookies->exists($this->request, 'our_cookie'));
 }