Jar
in package
implements
ArrayAccess, IteratorAggregate
Cookie holder object
Table of Contents
Interfaces
- ArrayAccess
- IteratorAggregate
Properties
- $cookies : array<string|int, mixed>
- Actual item data
Methods
- __construct() : mixed
- Create a new jar
- before_redirect_check() : mixed
- Parse all cookies from a response and attach them to the response
- before_request() : mixed
- Add Cookie header to a request if we have any
- getIterator() : ArrayIterator
- Get an iterator for the data
- normalize_cookie() : Cookie
- Normalise cookie data into a \WpOrg\Requests\Cookie
- offsetExists() : bool
- Check if the given item exists
- offsetGet() : string|null
- Get the value for the item
- offsetSet() : mixed
- Set the given item
- offsetUnset() : mixed
- Unset the given header
- register() : mixed
- Register the cookie handler with the request's hooking system
Properties
$cookies
Actual item data
protected
array<string|int, mixed>
$cookies
= []
Methods
__construct()
Create a new jar
public
__construct([array<string|int, mixed> $cookies = [] ]) : mixed
Parameters
- $cookies : array<string|int, mixed> = []
-
Existing cookie values
Tags
before_redirect_check()
Parse all cookies from a response and attach them to the response
public
before_redirect_check(Response $response) : mixed
Parameters
- $response : Response
-
Response as received.
before_request()
Add Cookie header to a request if we have any
public
before_request(string $url, array<string|int, mixed> &$headers, array<string|int, mixed> &$data, string &$type, array<string|int, mixed> &$options) : mixed
As per RFC 6265, cookies are separated by '; '
Parameters
- $url : string
- $headers : array<string|int, mixed>
- $data : array<string|int, mixed>
- $type : string
- $options : array<string|int, mixed>
getIterator()
Get an iterator for the data
public
getIterator() : ArrayIterator
Attributes
- #[ReturnTypeWillChange]
Return values
ArrayIteratornormalize_cookie()
Normalise cookie data into a \WpOrg\Requests\Cookie
public
normalize_cookie(string|Cookie $cookie[, string $key = '' ]) : Cookie
Parameters
- $cookie : string|Cookie
-
Cookie header value, possibly pre-parsed (object).
- $key : string = ''
-
Optional. The name for this cookie.
Return values
CookieoffsetExists()
Check if the given item exists
public
offsetExists(string $offset) : bool
Parameters
- $offset : string
-
Item key
Attributes
- #[ReturnTypeWillChange]
Return values
bool —Does the item exist?
offsetGet()
Get the value for the item
public
offsetGet(string $offset) : string|null
Parameters
- $offset : string
-
Item key
Attributes
- #[ReturnTypeWillChange]
Return values
string|null —Item value (null if offsetExists is false)
offsetSet()
Set the given item
public
offsetSet(string $offset, string $value) : mixed
Parameters
- $offset : string
-
Item name
- $value : string
-
Item value
Tags
Attributes
- #[ReturnTypeWillChange]
offsetUnset()
Unset the given header
public
offsetUnset(string $offset) : mixed
Parameters
- $offset : string
-
The key for the item to unset.
Attributes
- #[ReturnTypeWillChange]
register()
Register the cookie handler with the request's hooking system
public
register(HookManager $hooks) : mixed
Parameters
- $hooks : HookManager
-
Hooking system