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 47
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 63
protected int
currentTime()
Get the current system time as a UNIX timestamp.
in
InteractsWithTime at line 71
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 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 108
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 53
bool
has(UnitEnum|string $key)
Determine if a cookie exists in the current request.
at line 61
string|array|null
get(UnitEnum|string $key, string|array|null $default = null)
Get a cookie value from the current request.
at line 78
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 96
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).
This matches the recommended browser cookie lifetime limit.
at line 104
Cookie
forget(UnitEnum|string $name, string|null $path = null, string|null $domain = null)
Expire the given cookie.
at line 112
bool
hasQueued(UnitEnum|string $key, string|null $path = null)
Determine if a cookie has been queued.
at line 125
mixed
queued(UnitEnum|string $key, mixed $default = null, string|null $path = null)
Get a queued cookie instance.
at line 144
void
queue(mixed ...$parameters)
Queue a cookie to send with the next response.
at line 166
void
expire(UnitEnum|string $name, string|null $path = null, string|null $domain = null)
Queue a cookie to expire with the next response.
at line 174
void
unqueue(UnitEnum|string $name, string|null $path = null)
Remove a cookie from the queue.
at line 199
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 213
CookieJar
setDefaultPathAndDomain(string $path, string|null $domain, bool|null $secure = false, string|null $sameSite = null)
Set the default path and domain for the jar.
The defaults persist on the worker-lifetime singleton; per-request mutation races across coroutines and affects every subsequent request.
at line 226
array
getQueuedCookies()
Get the cookies which have been queued for the next request.
at line 236
CookieJar
flushQueuedCookies()
Flush the cookies which have been queued for the next request.
at line 248
protected array
getQueuedCookiesRaw()
Get the raw queued cookies array (keyed by name and path).
at line 258
protected void
setQueuedCookies(array $cookies)
Set the queued cookies in the coroutine context.
at line 266
static void
flushState()
Flush all static state.