$cookies
$cookies : array<mixed,\Cake\Http\Cookie\CookieInterface>
Cookie objects
Cookie Collection
Provides an immutable collection of cookies objects. Adding or removing to a collection returns a new collection that you must retain.
$cookies : array<mixed,\Cake\Http\Cookie\CookieInterface>
Cookie objects
createFromServerRequest(\Psr\Http\Message\ServerRequestInterface $request) : static
Create a new collection from the cookies in a ServerRequest
\Psr\Http\Message\ServerRequestInterface | $request | The request to extract cookie data from |
add(\Cake\Http\Cookie\CookieInterface $cookie) : static
Add a cookie and get an updated collection.
Cookies are stored by id. This means that there can be duplicate cookies if a cookie collection is used for cookies across multiple domains. This can impact how get(), has() and remove() behave.
\Cake\Http\Cookie\CookieInterface | $cookie | Cookie instance to add. |
get(string $name) : \Cake\Http\Cookie\CookieInterface|null
Get the first cookie by name.
string | $name | The name of the cookie. |
addToRequest(\Psr\Http\Message\RequestInterface $request, array $extraCookies = array()) : \Psr\Http\Message\RequestInterface
Add cookies that match the path/domain/expiration to the request.
This allows CookieCollections to be used as a 'cookie jar' in an HTTP client situation. Cookies that match the request's domain + path that are not expired when this method is called will be applied to the request.
\Psr\Http\Message\RequestInterface | $request | The request to update. |
array | $extraCookies | Associative array of additional cookies to add into the request. This is useful when you have cookie data from outside the collection you want to send. |
An updated request.
addFromResponse(\Psr\Http\Message\ResponseInterface $response, \Psr\Http\Message\RequestInterface $request) : static
Create a new collection that includes cookies from the response.
\Psr\Http\Message\ResponseInterface | $response | Response to extract cookies from. |
\Psr\Http\Message\RequestInterface | $request | Request to get cookie context from. |
findMatchingCookies(string $scheme, string $host, string $path) : array
Find cookies matching the scheme, host, and path
string | $scheme | The http scheme to match |
string | $host | The host to match. |
string | $path | The path to match |
An array of cookie name/value pairs
setRequestDefaults(array $cookies, string $host, string $path) : array
Apply path and host to the set of cookies if they are not set.
array | $cookies | An array of cookies to update. |
string | $host | The host to set. |
string | $path | The path to set. |
An array of updated cookies.
parseSetCookieHeader(array $values) : array<mixed,\Cake\Http\Cookie\Cookie>
Parse Set-Cookie headers into array
array | $values | List of Set-Cookie Header values. |
An array of cookie objects
Loading…