CookieStore
in package
implements
Countable, IteratorAggregate
The CookieStore object represents an immutable collection of `Cookie` value objects.
Tags
Table of Contents
Interfaces
- Countable
- IteratorAggregate
Properties
Methods
- __construct() : mixed
- clear() : void
- Clears the cookie collection.
- count() : int
- Gets the Cookie count in this collection.
- dispatch() : void
- Dispatches all cookies in store.
- display() : array<string, Cookie>
- Returns all cookie instances in store.
- fromCookieHeaders() : static
- Creates a CookieStore from an array of `Set-Cookie` headers.
- get() : Cookie
- Retrieves an instance of `Cookie` identified by a name and prefix.
- getIterator() : Traversable<string, Cookie>
- Gets the iterator for the cookie collection.
- has() : bool
- Checks if a `Cookie` object identified by name and prefix is present in the collection.
- put() : static
- Store a new cookie and return a new collection. The original collection is left unchanged.
- remove() : static
- Removes a cookie from a collection and returns an updated collection.
- setCookie() : void
- Extracted call to `setcookie()` in order to run unit tests on it.
- setRawCookie() : void
- Extracted call to `setrawcookie()` in order to run unit tests on it.
- validateCookies() : void
- Validates all cookies passed to be instances of Cookie.
Properties
$cookies
The cookie collection.
protected
array<string, Cookie>
$cookies
= []
Methods
__construct()
public
final __construct(array<string|int, Cookie> $cookies) : mixed
Parameters
- $cookies : array<string|int, Cookie>
Tags
clear()
Clears the cookie collection.
public
clear() : void
count()
Gets the Cookie count in this collection.
public
count() : int
Return values
intdispatch()
Dispatches all cookies in store.
public
dispatch() : void
Response should dispatch cookies.
display()
Returns all cookie instances in store.
public
display() : array<string, Cookie>
Return values
array<string, Cookie>fromCookieHeaders()
Creates a CookieStore from an array of `Set-Cookie` headers.
public
static fromCookieHeaders(array<int, string> $headers[, bool $raw = false ]) : static
Parameters
- $headers : array<int, string>
- $raw : bool = false
Tags
Return values
staticget()
Retrieves an instance of `Cookie` identified by a name and prefix.
public
get(string $name[, string $prefix = '' ]) : Cookie
This throws an exception if not found.
Parameters
- $name : string
- $prefix : string = ''
Tags
Return values
CookiegetIterator()
Gets the iterator for the cookie collection.
public
getIterator() : Traversable<string, Cookie>
Return values
Traversable<string, Cookie>has()
Checks if a `Cookie` object identified by name and prefix is present in the collection.
public
has(string $name[, string $prefix = '' ][, string|null $value = null ]) : bool
Parameters
- $name : string
- $prefix : string = ''
- $value : string|null = null
Return values
boolput()
Store a new cookie and return a new collection. The original collection is left unchanged.
public
put(Cookie $cookie) : static
Parameters
- $cookie : Cookie
Return values
staticremove()
Removes a cookie from a collection and returns an updated collection.
public
remove(string $name[, string $prefix = '' ]) : static
The original collection is left unchanged.
Removing a cookie from the store DOES NOT delete it from the browser. If you intend to delete a cookie from the browser, you must put an empty value cookie with the same name to the store.
Parameters
- $name : string
- $prefix : string = ''
Return values
staticsetCookie()
Extracted call to `setcookie()` in order to run unit tests on it.
protected
setCookie(string $name, string $value, array<string|int, mixed> $options) : void
Parameters
- $name : string
- $value : string
- $options : array<string|int, mixed>
Tags
setRawCookie()
Extracted call to `setrawcookie()` in order to run unit tests on it.
protected
setRawCookie(string $name, string $value, array<string|int, mixed> $options) : void
Parameters
- $name : string
- $value : string
- $options : array<string|int, mixed>
Tags
validateCookies()
Validates all cookies passed to be instances of Cookie.
protected
validateCookies(array<string|int, mixed> $cookies) : void
Parameters
- $cookies : array<string|int, mixed>