class Cookies implements Countable, IteratorAggregate

Cookies.

Properties

protected array $defaults Default options.
protected array $cookies Cookies.
protected Signer $signer Signer instance.

Methods

__construct(Signer|null $signer = null)

Constructor.

int
count()

Returns the numner of cookies.

getIterator()

Retruns an array iterator object.

setOptions(array $defaults)

Set default options values.

add(string $name, string $value, int $ttl = 0, array $options = [], bool $raw = false)

Adds a unsigned cookie.

addRaw(string $name, string $value, int $ttl = 0, array $options = [])

Adds a raw unsigned cookie.

addSigned(string $name, string $value, int $ttl = 0, array $options = [], bool $raw = false)

Adds a signed cookie.

addRawSigned(string $name, string $value, int $ttl, array $options = [])

Adds a raw signed cookie.

bool
has(string $name)

Returns TRUE if the cookie exists and FALSE if not.

remove(string $name)

Removes a cookie.

delete(string $name, array $options = [])

Deletes a cookie.

clear()

Clears all the cookies.

array
all()

Returns all the cookies.

Details

at line 57
__construct(Signer|null $signer = null)

Constructor.

Parameters

Signer|null $signer Signer

at line 67
int count()

Returns the numner of cookies.

Return Value

int

at line 77
ArrayIterator getIterator()

Retruns an array iterator object.

Return Value

ArrayIterator

at line 88
Cookies setOptions(array $defaults)

Set default options values.

Parameters

array $defaults Default option values

Return Value

Cookies

at line 105
Cookies add(string $name, string $value, int $ttl = 0, array $options = [], bool $raw = false)

Adds a unsigned cookie.

Parameters

string $name Cookie name
string $value Cookie value
int $ttl Time to live - if omitted or set to 0 the cookie will expire when the browser closes
array $options Cookie options
bool $raw Set the cookie without urlencoding the value?

Return Value

Cookies

at line 129
Cookies addRaw(string $name, string $value, int $ttl = 0, array $options = [])

Adds a raw unsigned cookie.

Parameters

string $name Cookie name
string $value Cookie value
int $ttl Time to live - if omitted or set to 0 the cookie will expire when the browser closes
array $options Cookie options

Return Value

Cookies

at line 144
Cookies addSigned(string $name, string $value, int $ttl = 0, array $options = [], bool $raw = false)

Adds a signed cookie.

Parameters

string $name Cookie name
string $value Cookie value
int $ttl Time to live - if omitted or set to 0 the cookie will expire when the browser closes
array $options Cookie options
bool $raw Set the cookie without urlencoding the value?

Return Value

Cookies

at line 163
Cookies addRawSigned(string $name, string $value, int $ttl, array $options = [])

Adds a raw signed cookie.

Parameters

string $name Cookie name
string $value Cookie value
int $ttl Time to live - if omitted or set to 0 the cookie will expire when the browser closes
array $options Cookie options

Return Value

Cookies

at line 174
bool has(string $name)

Returns TRUE if the cookie exists and FALSE if not.

Parameters

string $name Cookie name

Return Value

bool

at line 185
Cookies remove(string $name)

Removes a cookie.

Parameters

string $name Cookie name

Return Value

Cookies

at line 199
Cookies delete(string $name, array $options = [])

Deletes a cookie.

Parameters

string $name Cookie name
array $options Cookie options

Return Value

Cookies

at line 211
Cookies clear()

Clears all the cookies.

Return Value

Cookies

at line 223
array all()

Returns all the cookies.

Return Value

array