Serialize Response cookies into raw HTTP header
@param  \Yee\Http\Headers $headers The Response headers
@param  \Yee\Http\Cookies $cookies The Response cookies
@param  array              $config  The Yee app settings
18048
public static function serializeCookies(\Yee\Http\Headers &$headers, \Yee\Http\Cookies $cookies, array $config)
    {
        if ($config['cookies.encrypt']) {
            foreach ($cookies as $name => $settings) {
                if (is_string($settings['expires'])) {
                    $expires = strtotime($settings['expires']);
                } else {
                    $expires = (int) $settings['expires'];
                }

                $settings['value'] = static::encodeSecureCookie(
                    $settings['value'],
                    $expires,
                    $config['cookies.secret_key'],
                    $config['cookies.cipher'],
                    $config['cookies.cipher_mode']
                );
                static::setCookieHeader($headers, $name, $settings);
            }
        } else {
            foreach ($cookies as $name => $settings) {
                static::setCookieHeader($headers, $name, $settings);
            }
        }
    }
280954
public final function cookies(array $cookies = null): array
    {
        return ($cookies == null) ? $this->getCookies() : $this->getCookies($cookies);
    }
62459
private function setReponseHeaders($contentType = 'text/html', array $cookies = array())
    {
        $powered = Config::getParam('poweredBy', 'PSFS');
        header('X-Powered-By: ' . $powered);
        ResponseHelper::setStatusHeader($this->getStatusCode());
        ResponseHelper::setAuthHeaders($this->isPublicZone());
        ResponseHelper::setCookieHeaders($cookies);
        header('Content-type: ' . $contentType);

    }
758032
protected function getResponseWithHeaders(Response $responseConfig, ResponseInterface $httpResponse)
    {
        if ($responseConfig->getHeaders()) {
            foreach ($responseConfig->getHeaders() as $name => $value) {
                $httpResponse = $httpResponse->withHeader($name, $value);
            }
        }

        return $httpResponse;
    }
930091
def handle_cookies(response, exc=None):
    '''
    '''
    if exc:
        return
    headers = response.headers
    request = response.request
    client = request.client
    response._cookies = c = SimpleCookie()
    if 'set-cookie' in headers or 'set-cookie2' in headers:
        for cookie in (headers.get('set-cookie2'),
                       headers.get('set-cookie')):
            if cookie:
                c.load(cookie)
        if client.store_cookies:
            client.cookies.extract_cookies(response, request)
1003278
public function setCookie(RequestCookie $cookie)
    {
        $this->cookies[$cookie->getName()] = $cookie;
        $this->setHeadersFromCookies();
    }
1100917
public function exposeHeaders($headers = '*')
    {
        $this->response = $this->corsHandler->setResponse($this->response)
            ->exposeHeaders($headers)
            ->getResponse();

        return $this;
    }
1123732
protected static function header($headerKey, $headerValue, ResponseContract $response = null)
    {
        if ($response) {
            $response->setHeader($headerKey, $headerValue);
        } else {
            ResponseKit::setHeader($headerKey, $headerValue);
        }
    }
329041
public function modify(HeaderBag &$headers)
    {
        foreach ($headers->getByName('set-cookie') as $cookieHeader)
        {
            $cookieName = $cookieHeader->getFirstAttributeName();

            if ( ! $cookieHeader->hasAttribute($this->field) and $this->isCandidateCookie($cookieName))
            {
                $cookieHeader->setAttribute($this->field, $this->value);
            }
        }
    }
944321
private static function headers() {
        if (empty(self::$config['httpHeaders'])) {
            return;
        }

        $response = self::$config['httpContext']->getResponse();
        $response->setHeaders(self::$config['httpHeaders']);
    }
575819
public function parseHeader($header)
    {
        $header = rtrim($header, "\r\n");
        $pieces = preg_split('@\s*[;,]\s*@', $header);
        $cookies = array();

        foreach ($pieces as $cookie) {
            $cookie = explode('=', $cookie, 2);

            if (count($cookie) === 2) {
                $key = urldecode($cookie[0]);
                $value = urldecode($cookie[1]);

                if (!isset($cookies[$key])) {
                    $cookies[$key] = $value;
                }
            }
        }

        return $cookies;
    }
236965
protected function cookie($config)
    {
        $minutes = (!$config['expire_on_close']) ? $config['lifetime'] : 0;

        Cookie::put($config['cookie'], $this->session['id'], $minutes, $config['path'], $config['domain'],
            $config['secure']);
    }
1049401
public function setCookies(array $cookies) : Request
    {
        $query = http_build_query($cookies);
        parse_str($query, $this->cookies);

        if ($cookies) {
            $cookie = str_replace('&', '; ', $query);
            $this->setHeader('Cookie', $cookie);
        } else {
            $this->removeHeader('Cookie');
        }

        return $this;
    }
1254164
protected function _parseCookies($header) {
		$cookies = array_map('trim', array_filter(explode('; ', $header)));
		foreach ($cookies as $cookie) {
			list($name, $value) = array_map('urldecode', explode('=', $cookie, 2)) + ['',''];
			$this->cookies($name, $value);
		}
	}
1225165
public function setCookie($cookies = [])
    {
        $this->cookies = $cookies;
        $this->debug->info(__FUNCTION__, 'setCookie: ', $this->cookies);

        return $this;
    }
228497
public function addCookies(array $cookies)
    {
        $cookieCollection = $this->getCookies();
        foreach ($cookies as $cookie) {
            if (!is_object($cookie)) {
                $cookie = new Cookie($cookie);
            }
            $cookieCollection->add($cookie);
        }
        return $this;
    }
496787
public function initialize(array $config) {
        parent::initialize($config);

        // set request
        $this->ctrl = $this->getController();
        $this->cookies = (new CookieCollection())->createFromServerRequest($this->ctrl->getRequest());
    }