protected function addCookieToResponse(
        ServerRequestInterface $request,
        ResponseInterface $response,
        StoreContract $session
    ): ResponseInterface {
        if ($session->getHandler() instanceof CookieSessionHandler) {
            $session->save();
        }

        $uri    = $request->getUri();

        $setCookie = new SetCookie(
            $session->getName(),
            $session->getId(),
            $this->cookieConfig['expire_on_close'] === true ? 0 : Chronos::now()->addSeconds($this->lifetime),
            $this->cookieConfig['path'] ?? '/',
            $this->cookieConfig['domain'] ?? $uri->getHost(),
            $this->cookieConfig['secure'] ?? ($uri->getScheme() === 'https'),
            $this->cookieConfig['http_only'] ?? true,
            $this->cookieConfig['samesite'] ?? false
        );

        return $response->withAddedHeader('set-cookie', (string) $setCookie);
    }
protected function addCookieToResponse(
        ServerRequestInterface $request,
        ResponseInterface $response,
        StoreContract $session
    ): ResponseInterface {
        if ($session->getHandler() instanceof CookieSessionHandler) {
            $session->save();
        }

        $uri    = $request->getUri();

        $setCookie = new SetCookie(
            $session->getName(),
            $session->getId(),
            $this->cookieConfig['expire_on_close'] === true ? 0 : Chronos::now()->addSeconds($this->lifetime),
            $this->cookieConfig['path'] ?? '/',
            $this->cookieConfig['domain'] ?? $uri->getHost(),
            $this->cookieConfig['secure'] ?? ($uri->getScheme() === 'https'),
            $this->cookieConfig['http_only'] ?? true,
            $this->cookieConfig['samesite'] ?? false
        );

        return $response->withAddedHeader('set-cookie', (string) $setCookie);
    }
protected function addCookieToResponse ( ServerRequestInterface $ request , ResponseInterface $ response , StoreContract $ session ) : ResponseInterface { if ( $ session -> getHandler ( ) instanceof CookieSessionHandler ) { $ session -> save ( ) ; } $ uri = $ request -> getUri ( ) ; $ setCookie = new SetCookie ( $ session -> getName ( ) , $ session -> getId ( ) , $ this -> cookieConfig [ 'expire_on_close' ] === true ? 0 : Chronos :: now ( ) -> addSeconds ( $ this -> lifetime ) , $ this -> cookieConfig [ 'path' ] ?? '/' , $ this -> cookieConfig [ 'domain' ] ?? $ uri -> getHost ( ) , $ this -> cookieConfig [ 'secure' ] ?? ( $ uri -> getScheme ( ) === 'https' ) , $ this -> cookieConfig [ 'http_only' ] ?? true , $ this -> cookieConfig [ 'samesite' ] ?? false ) ; return $ response -> withAddedHeader ( 'set-cookie' , ( string ) $ setCookie ) ; }
Add the session cookie to the application response.

@param \Psr\Http\Message\ServerRequestInterface  $request
@param \Psr\Http\Message\ResponseInterface       $response
@param \Viserio\Component\Contract\Session\Store $session

@throws \Viserio\Component\Contract\Cookie\Exception\InvalidArgumentException

@return \Psr\Http\Message\ResponseInterface
Add the session cookie to the application response .