protected function addCookieToResponse(
        ServerRequestInterface $request,
        ResponseInterface $response
    ): ResponseInterface {
        $uri = $request->getUri();

        $setCookie = new SetCookie(
            'XSRF-TOKEN',
            $request->getAttribute('session')->getToken(),
            $this->lifetime,
            $this->cookieConfig['path'],
            $this->cookieConfig['domain'] ?? $uri->getHost(),
            $this->cookieConfig['secure'] ?? ($uri->getScheme() === 'https'),
            false,
            $this->cookieConfig['samesite']
        );

        return $response->withAddedHeader('set-cookie', (string) $setCookie);
    }
protected function addCookieToResponse(
        ServerRequestInterface $request,
        ResponseInterface $response
    ): ResponseInterface {
        $uri = $request->getUri();

        $setCookie = new SetCookie(
            'XSRF-TOKEN',
            $request->getAttribute('session')->getToken(),
            $this->lifetime,
            $this->cookieConfig['path'],
            $this->cookieConfig['domain'] ?? $uri->getHost(),
            $this->cookieConfig['secure'] ?? ($uri->getScheme() === 'https'),
            false,
            $this->cookieConfig['samesite']
        );

        return $response->withAddedHeader('set-cookie', (string) $setCookie);
    }
protected function addCookieToResponse ( ServerRequestInterface $ request , ResponseInterface $ response ) : ResponseInterface { $ uri = $ request -> getUri ( ) ; $ setCookie = new SetCookie ( 'XSRF-TOKEN' , $ request -> getAttribute ( 'session' ) -> getToken ( ) , $ this -> lifetime , $ this -> cookieConfig [ 'path' ] , $ this -> cookieConfig [ 'domain' ] ?? $ uri -> getHost ( ) , $ this -> cookieConfig [ 'secure' ] ?? ( $ uri -> getScheme ( ) === 'https' ) , false , $ this -> cookieConfig [ 'samesite' ] ) ; return $ response -> withAddedHeader ( 'set-cookie' , ( string ) $ setCookie ) ; }
Add the CSRF token to the response cookies.

@param \Psr\Http\Message\ServerRequestInterface $request
@param \Psr\Http\Message\ResponseInterface      $response

@throws \InvalidArgumentException

@return \Psr\Http\Message\ResponseInterface
Add the CSRF token to the response cookies .