Add the CSRF token to the response cookies.

@param  \Nova\Http\Request  $request
@param  \Nova\Http\Response  $response
@return \Nova\Http\Response
429733
protected function addCookieToResponse($request, $response)
    {
        $config = $this->app['config']['session'];

        $cookie = new Cookie(
            'XSRF-TOKEN',
            $request->session()->token(),
            time() + 60 * 120,
            $config['path'],
            $config['domain'],
            $config['secure'], false
        );

        $response->headers->setCookie($cookie);

        return $response;
    }
1111566
public function persist(Response $response)
    {
        $trackingParameters = $this->trackingParameters->all();

        foreach ($trackingParameters as $trackingParameter => $value) {
            if (
                (null !== $value)
                && (true === in_array($trackingParameter, $this->cookiesToSave))
            ) {
                $response->headers->setCookie(new Cookie(
                    $trackingParameter,
                    $value,
                    new \DateTime('+1 year'),
                    '/',
                    null,
                    false,
                    false
                ));
            }
        }

        return $response;
    }
756820
protected function setAccessControlAllowOriginHeader(Request $request, Response $response): Response
    {
        $origin = $request->headers->get('Origin');

        if ($this->isAllOriginsAllowed()) {
            $response->headers->set('Access-Control-Allow-Origin', '*');
        } elseif ($this->isOriginAllowed($origin)) {
            $response->headers->set('Access-Control-Allow-Origin', $origin);
        }

        return $response;
    }
75336
private function haveSameOrigin(Request $request, Response $response)
    {
        $requestOrigin = $this->getUrlOrigin($request->headers->get(self::ORIGIN_REQUEST_HEADER));
        $responseOrigin = $this->getUrlOrigin($response->headers->get(self::ORIGIN_RESPONSE_HEADER));

        return $requestOrigin == $responseOrigin;
    }
601935
public function update(Response $response)
    {
        $flatCookies = $response->headers->getCookies();
        $cookies = [];

        $getCookieId = function (Cookie $cookie) {
            return $cookie->getDomain() . '|' . $cookie->getPath() . '|' . $cookie->getName();
        };

        /** @var Cookie $cookie */
        foreach ($flatCookies as $cookie) {
            $cookies[$getCookieId($cookie)] = $cookie;
        }

        foreach ($this->cookieModels as $cookieModel) {
            $cookie = $cookieModel->toCookie();

            if ($cookieModel->getClear()) {
                $response->headers->clearCookie($cookie->getName(), $cookie->getPath(), $cookie->getDomain());
            } elseif (!isset($cookies[$getCookieId($cookie)]) && $cookieModel->isDirty()) {
                $response->headers->setCookie($cookieModel->toCookie());
            }
        }
    }
907508
public static function fromResponse(ResponseInterface $response) : SetCookies
    {
        return new static(array_map(function (string $setCookieString) : SetCookie {
            return SetCookie::fromSetCookieString($setCookieString);
        }, $response->getHeader(static::SET_COOKIE_HEADER)));
    }
160914
public function process(Request $request, Response $response)
    {
        // Conditionally add jQuery
        $this->addJquery($request, $response);

        /** @var FileAssetInterface $asset */
        foreach ($this->sort($this->javascript) as $key => $asset) {
            $this->processAsset($asset, $request, $response);
            unset($this->javascript[$key]);
        }

        /** @var FileAssetInterface $asset */
        foreach ($this->sort($this->stylesheet) as $key => $asset) {
            $this->processAsset($asset, $request, $response);
            unset($this->stylesheet[$key]);
        }
    }
572692
protected function writeQueuedCookies(Response $response)
    {
        foreach ($this->queue->getQueuedCookies() as $cookie) {
            $response->headers->setCookie($cookie);
        }
    }
1290348
protected function setUriHeader(Response $response, Request $request)
    {
        $response->header('X-PJAX-URL', $request->getRequestUri());

        return $this;
    }
1020804
public function resolve(Request $request, Response $response)
    {
        return $response->methodNotAllowed(
                $request->method(),
                $this->allowedMethods
        );
    }
907068
public function addFromResponse(ResponseInterface $response, RequestInterface $request)
    {
        $uri = $request->getUri();
        $host = $uri->getHost();
        $path = $uri->getPath() ?: '/';

        $cookies = static::parseSetCookieHeader($response->getHeader('Set-Cookie'));
        $cookies = $this->setRequestDefaults($cookies, $host, $path);
        $new = clone $this;
        foreach ($cookies as $cookie) {
            $new->cookies[$cookie->getId()] = $cookie;
        }
        $new->removeExpiredCookies($host, $path);

        return $new;
    }
522268
protected function addCookieToResponse(Response $response, SessionInterface $session)
	{
		$s = $session;

		if ($this->sessionIsPersistent($c = $this->manager->getSessionConfig()))
		{
			$secure = array_get($c, 'secure', false);

			$response->headers->setCookie(new Cookie(
				$s->getName(), $s->getId(), $this->getCookieLifetime(), $c['path'], $c['domain'], $secure
			));
		}
	}
346708
public function handleResponse(Response $response) : void
    {
        if ($this->id === null) {
            // The request was not associated with an existing session, and no session writes occurred.
            // Sending a session cookie is unnecessary.
            return;
        }

        // Note: we re-send the session cookie even if it was part of the request, to refresh the expiration time.

        $this->writeSessionId($response);
        $this->reset();
    }
625803
public function register(
        ServerRequestInterface $request, ResponseInterface $response
    ) {
        $this->request = $request;
        $this->response = $response;
        return $this;
    }
1235072
public function bind($response) {
		$this->_response = $response;
		$this->_response->headers += $this->_headers;

		foreach ($this->_queue as $message) {
			$this->_write($message);
		}
	}
497029
protected function encrypt(Response $response)
    {
        foreach ($response->headers->getCookies() as $cookie) {
            if ($this->isDisabled($cookie->getName())) {
                continue;
            }

            $response->headers->setCookie($this->duplicate(
                $cookie, $this->encrypter->encrypt($cookie->getValue(), static::serialized($cookie->getName()))
            ));
        }

        return $response;
    }
1125946
public function render(Request $request, Response $response) {
        $key = $response->getResults('captcha');

        $content = $response->getContent();
        $content .= '<script src="https://www.google.com/recaptcha/api.js"></script>';
        $content .= '<div class="form-group"><div class="g-recaptcha" '
                    . 'data-sitekey="'.$key.'"></div></div>';
        $response->setContent($content);

        return $this;
    }