API / Minn\Http / CookieText

CookieText final class

Minn\Http\CookieText · public/minn/src/Minn/Http/CookieText.php · 94 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 "/".