CookieJar
class CookieJar implements QueueingFactory
Traits
Constants
| protected QUEUE_CONTEXT_KEY |
Context key for the queued cookies. |
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|null | $sameSite | The default SameSite option (defaults to lax). |
Methods
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Determine if a cookie exists in the current request.
Get a cookie value from the current request.
Create a new cookie instance.
Create a cookie that lasts "forever" (400 days).
Expire the given cookie.
Determine if a cookie has been queued.
Get a queued cookie instance.
Queue a cookie to send with the next response.
Queue a cookie to expire with the next response.
Remove a cookie from the queue.
Get the path and domain, or the default values.
Set the default path and domain for the jar.
Get the cookies which have been queued for the next request.
Flush the cookies which have been queued for the next request.
Get the raw queued cookies array (keyed by name and path).
Set the queued cookies in the coroutine context.
Flush all static state.
Details
in
InteractsWithTime at line 17
protected int
secondsUntil(DateInterval|DateTimeInterface|int $delay)
Get the number of seconds until the given DateTime.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
in
InteractsWithTime at line 41
protected DateTimeInterface|int
parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)
If the given value is an interval, convert it to a DateTime instance.
in
InteractsWithTime at line 57
protected int
currentTime()
Get the current system time as a UNIX timestamp.
in
InteractsWithTime at line 65
protected string
runTimeForHumans(float $startTime, float|null $endTime = null)
Given a start time, format the total run time for human readability.
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 51
bool
has(UnitEnum|string $key)
Determine if a cookie exists in the current request.
at line 59
string|array|null
get(UnitEnum|string $key, string|array|null $default = null)
Get a cookie value from the current request.
at line 76
Cookie
make(UnitEnum|string $name, string|null $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.
at line 90
Cookie
forever(UnitEnum|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).
at line 98
Cookie
forget(UnitEnum|string $name, string|null $path = null, string|null $domain = null)
Expire the given cookie.
at line 106
bool
hasQueued(UnitEnum|string $key, string|null $path = null)
Determine if a cookie has been queued.
at line 116
mixed
queued(UnitEnum|string $key, mixed $default = null, string|null $path = null)
Get a queued cookie instance.
at line 131
void
queue(mixed ...$parameters)
Queue a cookie to send with the next response.
at line 153
void
expire(UnitEnum|string $name, string|null $path = null, string|null $domain = null)
Queue a cookie to expire with the next response.
at line 161
void
unqueue(UnitEnum|string $name, string|null $path = null)
Remove a cookie from the queue.
at line 186
protected array
getPathAndDomain(string|null $path, string|null $domain, bool|null $secure = null, string|null $sameSite = null)
Get the path and domain, or the default values.
at line 198
CookieJar
setDefaultPathAndDomain(string $path, string|null $domain, bool|null $secure = false, string|null $sameSite = null)
Set the default path and domain for the jar.
Boot-only. The defaults persist on the worker-lifetime singleton; per-request mutation races across coroutines and affects every subsequent request.
at line 210
array
getQueuedCookies()
Get the cookies which have been queued for the next request.
at line 218
CookieJar
flushQueuedCookies()
Flush the cookies which have been queued for the next request.
at line 228
protected array
getQueuedCookiesRaw()
Get the raw queued cookies array (keyed by name and path).
at line 236
protected void
setQueuedCookies(array $cookies)
Set the queued cookies in the coroutine context.
at line 244
static void
flushState()
Flush all static state.