API / Minn\Http / CookieText

CookieText final class

Minn\Http\CookieText · public/minn/src/Minn/Http/CookieText.php · 133 lines

Set-Cookie text and the matching rules a cookie jar applies: parsing a header into name, value and attributes; normalizing attributes (expires and max-age as timestamps, the domain without its leading dot); whether a cookie belongs to a domain and a path (RFC 6265).

Uses 1

Public

staticparse(string $header, string $name = ''): array#

A Set-Cookie value split up. With a name given, the first part is all value; a first part without "=" is a value with an empty name.

@return array{name: string, value: string, attributes: array<string, string|true>}
staticnormalizeAttribute(string $name, mixed $value, int $referenceTime): mixed#

One attribute normalized, or null when it should go: dates become timestamps, the domain loses its leading dot.

statichostMatches(?string $cookieDomain, string $domain): bool#

Whether a host-only cookie with this domain attribute (none means any) belongs to the domain: the same text only.

staticdomainMatches(?string $cookieDomain, string $domain): bool#

Whether a cookie with this domain attribute (none means any) belongs to the domain or one of its subdomains (never an IP address).

staticpathMatches(?string $cookiePath, string $requestPath): bool#

Whether a cookie with this path attribute (none means any) is sent for the request path.

staticdefaultPath(string $requestPath): string#

The path a cookie without one gets: the request path up to its last slash, or "/".

staticfields(array|string $data, string $requestedUrl, array $properties): array#

A cookie's fields, as WP_Http_Cookie sets them: from a Set-Cookie value (the value URL-decoded; expires, path, domain and port from its attributes; the domain and path it names none of from the URL it came from: the host, and the URL's directory), or from given fields that are among $properties (an expiry given as a date becomes a timestamp); the path "/" when nothing gives one.

$dataarray<string, mixed>|string
$propertieslist<string>
@return array<string, mixed>