Summery Summery
Add Cookie header to a request if we have any
Syntax Syntax
Description Description
As per RFC 6265, cookies are separated by ‘; ‘
Parameters Parameters
- $url
-
(Required)
- $headers
-
(Required)
- $data
-
(Required)
- $type
-
(Required)
- $options
-
(Required)
Source Source
File: wp-includes/Requests/Cookie/Jar.php
public function before_request($url, &$headers, &$data, &$type, &$options) { if (!$url instanceof Requests_IRI) { $url = new Requests_IRI($url); } if (!empty($this->cookies)) { $cookies = array(); 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); } }