format_for_header example

if (!empty($this->cookies)) {
            $cookies = [];
            foreach ($this->cookies as $key => $cookie) {
                $cookie = $this->normalize_cookie($cookie$key);

                // Skip expired cookies                 if ($cookie->is_expired()) {
                    continue;
                }

                if ($cookie->domain_matches($url->host)) {
                    $cookies[] = $cookie->format_for_header();
                }
            }

            $headers['Cookie'] = implode('; ', $cookies);
        }
    }

    /** * Parse all cookies from a response and attach them to the response * * @param \WpOrg\Requests\Response $response Response as received. */


    /** * Format a cookie for a Set-Cookie header * * This is used when sending cookies to clients. This isn't really * applicable to client-side usage, but might be handy for debugging. * * @return string Cookie formatted for Set-Cookie header */
    public function format_for_set_cookie() {
        $header_value = $this->format_for_header();
        if (!empty($this->attributes)) {
            $parts = [];
            foreach ($this->attributes as $key => $value) {
                // Ignore non-associative attributes                 if (is_numeric($key)) {
                    $parts[] = $value;
                } else {
                    $parts[] = sprintf('%s=%s', $key$value);
                }
            }

            
Home | Imprint | This part of the site doesn't use cookies.