Requests 2.0.0 API

Jar
in package
implements ArrayAccess, IteratorAggregate

Cookie holder object

Interfaces, Classes and Traits

ArrayAccess
IteratorAggregate

Table of Contents

$cookies  : array<string|int, mixed>
Actual item data
__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
throws
InvalidArgument

When the passed argument is not an array.

Return values
mixed

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
Return values
mixed

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>
Return values
mixed

getIterator()

Get an iterator for the data

public getIterator() : ArrayIterator
Return values
ArrayIterator

Normalise cookie data into a \WpOrg\Requests\Cookie

public normalize_cookie(string|Cookie $cookie[, mixed $key = '' ]) : Cookie
Parameters
$cookie : string|Cookie
$key : mixed = ''
Return values
Cookie

offsetExists()

Check if the given item exists

public offsetExists(string $offset) : bool
Parameters
$offset : string

Item key

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

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
throws
Exception

On attempting to use dictionary as list (invalidset)

Return values
mixed

offsetUnset()

Unset the given header

public offsetUnset(string $offset) : mixed
Parameters
$offset : string
Return values
mixed

register()

Register the cookie handler with the request's hooking system

public register(HookManager $hooks) : mixed
Parameters
$hooks : HookManager

Hooking system

Return values
mixed

Search results