class CookieJar implements QueueingFactory (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected string $path

The default path (if specified).

protected string|null $domain

The default domain (if specified).

protected bool|null $secure

The default secure setting (defaults to null).

protected string $sameSite

The default SameSite option (defaults to lax).

protected Cookie[] $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 = 0)

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.

string
runTimeForHumans(float $startTime, float $endTime = null)

Given a start time, format the total run time for human readability.

static void
macro(string $name, object|callable $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Checks if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

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

Create a new cookie instance.

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

Create a cookie that lasts "forever" (400 days).

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

Expire the given cookie.

bool
hasQueued(string $key, string|null $path = null)

Determine if a cookie has been queued.

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

Get a queued cookie instance.

void
queue(mixed ...$parameters)

Queue a cookie to send with the next response.

void
expire(string $name, string|null $path = null, string|null $domain = null)

Queue a cookie to expire with the next response.

void
unqueue(string $name, string|null $path = null)

Remove a cookie from the queue.

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

Get the path and domain, or the default values.

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

Set the default path and domain for the jar.

array
getQueuedCookies()

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

$this
flushQueuedCookies()

Flush 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 = 0)

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

protected string runTimeForHumans(float $startTime, float $endTime = null)

Given a start time, format the total run time for human readability.

Parameters

float $startTime
float $endTime

Return Value

string

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

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

Create a new cookie instance.

Parameters

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

Return Value

Cookie

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

Create a cookie that lasts "forever" (400 days).

Parameters

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

Return Value

Cookie

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

Expire the given cookie.

Parameters

string $name
string|null $path
string|null $domain

Return Value

Cookie

bool hasQueued(string $key, string|null $path = null)

Determine if a cookie has been queued.

Parameters

string $key
string|null $path

Return Value

bool

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

Get a queued cookie instance.

Parameters

string $key
mixed $default
string|null $path

Return Value

Cookie|null

void queue(mixed ...$parameters)

Queue a cookie to send with the next response.

Parameters

mixed ...$parameters

Return Value

void

void expire(string $name, string|null $path = null, string|null $domain = null)

Queue a cookie to expire with the next response.

Parameters

string $name
string|null $path
string|null $domain

Return Value

void

void unqueue(string $name, string|null $path = null)

Remove a cookie from the queue.

Parameters

string $name
string|null $path

Return Value

void

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

Get the path and domain, or the default values.

Parameters

string $path
string|null $domain
bool|null $secure
string|null $sameSite

Return Value

array

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

Set the default path and domain for the jar.

Parameters

string $path
string|null $domain
bool|null $secure
string|null $sameSite

Return Value

$this

array getQueuedCookies()

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

Return Value

array

$this flushQueuedCookies()

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

Return Value

$this