Documentation

CookieJar
in package
implements QueueingFactory Uses InteractsWithTime

Interfaces, Classes and Traits

QueueingFactory

Table of Contents

$domain  : string
The default domain (if specified).
$path  : string
The default path (if specified).
$queued  : array<string|int, Cookie>
All of the cookies queued for sending.
$sameSite  : string
The default SameSite option (if specified).
$secure  : bool
The default secure setting (defaults to false).
forever()  : Cookie
Create a cookie that lasts "forever" (five years).
forget()  : Cookie
Expire the given cookie.
getQueuedCookies()  : array<string|int, Cookie>
Get the cookies which have been queued for the next request.
hasQueued()  : bool
Determine if a cookie has been queued.
make()  : Cookie
Create a new cookie instance.
queue()  : void
Queue a cookie to send with the next response.
queued()  : Cookie
Get a queued cookie instance.
setDefaultPathAndDomain()  : $this
Set the default path and domain for the jar.
unqueue()  : void
Remove a cookie from the queue.
availableAt()  : int
Get the "available at" UNIX timestamp.
currentTime()  : int
Get the current system time as a UNIX timestamp.
getPathAndDomain()  : array<string|int, mixed>
Get the path and domain, or the default values.
parseDateInterval()  : DateTimeInterface|int
If the given value is an interval, convert it to a DateTime instance.
secondsUntil()  : int
Get the number of seconds until the given DateTime.

Properties

$domain

The default domain (if specified).

protected string $domain

$path

The default path (if specified).

protected string $path = '/'

$queued

All of the cookies queued for sending.

protected array<string|int, Cookie> $queued = []

$sameSite

The default SameSite option (if specified).

protected string $sameSite

$secure

The default secure setting (defaults to false).

protected bool $secure = false

Methods

forever()

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

public forever(string $name, string $value[, string $path = null ][, string $domain = null ][, bool $secure = false ][, bool $httpOnly = true ][, bool $raw = false ][, string|null $sameSite = null ]) : Cookie
Parameters
$name : string
$value : string
$path : string = null
$domain : string = null
$secure : bool = false
$httpOnly : bool = true
$raw : bool = false
$sameSite : string|null = null
Return values
Cookie

forget()

Expire the given cookie.

public forget(string $name[, string $path = null ][, string $domain = null ]) : Cookie
Parameters
$name : string
$path : string = null
$domain : string = null
Return values
Cookie

getQueuedCookies()

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

public getQueuedCookies() : array<string|int, Cookie>
Return values
array<string|int, Cookie>

hasQueued()

Determine if a cookie has been queued.

public hasQueued(string $key) : bool
Parameters
$key : string
Return values
bool

make()

Create a new cookie instance.

public 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 ]) : Cookie
Parameters
$name : string
$value : string
$minutes : int
$path : string = null
$domain : string = null
$secure : bool = false
$httpOnly : bool = true
$raw : bool = false
$sameSite : string|null = null
Return values
Cookie

queue()

Queue a cookie to send with the next response.

public queue(array<string|int, mixed> ...$parameters) : void
Parameters
$parameters : array<string|int, mixed>
Return values
void

queued()

Get a queued cookie instance.

public queued(string $key[, mixed $default = null ]) : Cookie
Parameters
$key : string
$default : mixed = null
Return values
Cookie

setDefaultPathAndDomain()

Set the default path and domain for the jar.

public setDefaultPathAndDomain(string $path, string $domain[, bool $secure = false ][, string $sameSite = null ]) : $this
Parameters
$path : string
$domain : string
$secure : bool = false
$sameSite : string = null
Return values
$this

unqueue()

Remove a cookie from the queue.

public unqueue(string $name) : void
Parameters
$name : string
Return values
void

availableAt()

Get the "available at" UNIX timestamp.

protected availableAt(DateTimeInterface|DateInterval|int $delay) : int
Parameters
$delay : DateTimeInterface|DateInterval|int
Return values
int

currentTime()

Get the current system time as a UNIX timestamp.

protected currentTime() : int
Return values
int

getPathAndDomain()

Get the path and domain, or the default values.

protected getPathAndDomain(string $path, string $domain[, bool $secure = false ][, string $sameSite = null ]) : array<string|int, mixed>
Parameters
$path : string
$domain : string
$secure : bool = false
$sameSite : string = null
Return values
array<string|int, mixed>

parseDateInterval()

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

protected parseDateInterval(DateTimeInterface|DateInterval|int $delay) : DateTimeInterface|int
Parameters
$delay : DateTimeInterface|DateInterval|int
Return values
DateTimeInterface|int

secondsUntil()

Get the number of seconds until the given DateTime.

protected secondsUntil(DateTimeInterface|DateInterval|int $delay) : int
Parameters
$delay : DateTimeInterface|DateInterval|int
Return values
int

Search results