class CookieJar implements QueueingFactory (View source)

Traits

Properties

protected string $path The default path (if specified).
protected string $domain The default domain (if specified).
protected bool $secure The default secure setting (defaults to false).
protected string $sameSite The default SameSite option (if specified).
protected array $queued All of the cookies queued for sending.

Methods

int
secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

int
availableAt(DateTimeInterface|DateInterval|int $delay)

Get the "available at" UNIX timestamp.

parseDateInterval(DateTimeInterface|DateInterval|int $delay)

If the given value is an interval, convert it to a DateTime instance.

int
currentTime()

Get the current system time as a UNIX timestamp.

Cookie
make(string $name, string $value, int $minutes, string $path = null, string $domain = null, bool $secure = false, bool $httpOnly = true, bool $raw = false, string|null $sameSite = null)

Create a new cookie instance.

Cookie
forever(string $name, string $value, string $path = null, string $domain = null, bool $secure = false, bool $httpOnly = true, bool $raw = false, string|null $sameSite = null)

Create a cookie that lasts "forever" (five years).

Cookie
forget(string $name, string $path = null, string $domain = null)

Expire the given cookie.

bool
hasQueued(string $key)

Determine if a cookie has been queued.

Cookie
queued(string $key, mixed $default = null)

Get a queued cookie instance.

void
queue(array $parameters)

Queue a cookie to send with the next response.

unqueue(string $name)

Remove a cookie from the queue.

array
getPathAndDomain(string $path, string $domain, bool $secure = false, string $sameSite = null)

Get the path and domain, or the default values.

$this
setDefaultPathAndDomain(string $path, string $domain, bool $secure = false, string $sameSite = null)

Set the default path and domain for the jar.

array
getQueuedCookies()

Get the cookies which have been queued for the next request.

Details

protected int secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

protected int availableAt(DateTimeInterface|DateInterval|int $delay)

Get the "available at" UNIX timestamp.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

protected DateTimeInterface|int parseDateInterval(DateTimeInterface|DateInterval|int $delay)

If the given value is an interval, convert it to a DateTime instance.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

DateTimeInterface|int

protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

Cookie make(string $name, string $value, int $minutes, string $path = null, string $domain = null, bool $secure = false, bool $httpOnly = true, bool $raw = false, string|null $sameSite = null)

Create a new cookie instance.

Parameters

string $name
string $value
int $minutes
string $path
string $domain
bool $secure
bool $httpOnly
bool $raw
string|null $sameSite

Return Value

Cookie

Cookie forever(string $name, string $value, string $path = null, string $domain = null, bool $secure = false, bool $httpOnly = true, bool $raw = false, string|null $sameSite = null)

Create a cookie that lasts "forever" (five years).

Parameters

string $name
string $value
string $path
string $domain
bool $secure
bool $httpOnly
bool $raw
string|null $sameSite

Return Value

Cookie

Cookie forget(string $name, string $path = null, string $domain = null)

Expire the given cookie.

Parameters

string $name
string $path
string $domain

Return Value

Cookie

bool hasQueued(string $key)

Determine if a cookie has been queued.

Parameters

string $key

Return Value

bool

Cookie queued(string $key, mixed $default = null)

Get a queued cookie instance.

Parameters

string $key
mixed $default

Return Value

Cookie

void queue(array $parameters)

Queue a cookie to send with the next response.

Parameters

array $parameters

Return Value

void

unqueue(string $name)

Remove a cookie from the queue.

Parameters

string $name

protected array getPathAndDomain(string $path, string $domain, bool $secure = false, string $sameSite = null)

Get the path and domain, or the default values.

Parameters

string $path
string $domain
bool $secure
string $sameSite

Return Value

array

$this setDefaultPathAndDomain(string $path, string $domain, bool $secure = false, string $sameSite = null)

Set the default path and domain for the jar.

Parameters

string $path
string $domain
bool $secure
string $sameSite

Return Value

$this

array getQueuedCookies()

Get the cookies which have been queued for the next request.

Return Value

array