class CookieJar (View source)

A class that holds operations performed on both request and response cookies.

To work only on request cookies, use the Request class. To work only on response cookies, use the ResponseCookieJar class.

Properties

protected Request $request

The object containing the request cookies.

protected ResponseCookieJar $responseCookies

The object containing the response cookies.

Methods

__construct(Request $request, ResponseCookieJar $responseCookies)

Initialize the instance.

getResponseCookies()

Get the object containing the response cookies.

bool
has(string $name)

Does a cookie exist in the request or response cookies?

mixed
get(string $name, mixed $default = null)

Get the value of a cookie (from response or from request) given its name.

array
getAll()

Get a list of cookie names and values (both from response and from request).

setRequest(Request $request)

Set the request for this cookie jar.

Cookie
set(string $name, string|null $value = null, int $expire = 0, string $path = '/', null|string $domain = null, bool $secure = false, bool $httpOnly = true) deprecated

No description

add(Cookie $cookie) deprecated

No description

clear(string $name) deprecated

No description

Cookie[]
getCookies() deprecated

No description

getRequest()

Get the request for this cookie jar.

Details

__construct(Request $request, ResponseCookieJar $responseCookies)

Initialize the instance.

Parameters

Request $request

the object containing the request cookies

ResponseCookieJar $responseCookies

the object containing the response cookies

ResponseCookieJar getResponseCookies()

Get the object containing the response cookies.

Return Value

ResponseCookieJar

bool has(string $name)

Does a cookie exist in the request or response cookies?

Parameters

string $name

Return Value

bool

mixed get(string $name, mixed $default = null)

Get the value of a cookie (from response or from request) given its name.

Parameters

string $name

The key the cookie

mixed $default

The value to return if the cookie isn't set

Return Value

mixed

array getAll()

Get a list of cookie names and values (both from response and from request).

Return Value

array

array keys are the cookie names, array values are the cookie values

setRequest(Request $request)

Set the request for this cookie jar.

Parameters

Request $request

Cookie set(string $name, string|null $value = null, int $expire = 0, string $path = '/', null|string $domain = null, bool $secure = false, bool $httpOnly = true) deprecated

deprecated Use ->getResponseCookies()->addCookie() or $app->make(ResponseCookieJar::class)->addCookie()

No description

Parameters

string $name
string|null $value
int $expire
string $path
null|string $domain
bool $secure
bool $httpOnly

Return Value

Cookie

add(Cookie $cookie) deprecated

deprecated Use ->getResponseCookies()->addCookieObject() or $app->make(ResponseCookieJar::class)->addCookieObject()

No description

Parameters

Cookie $cookie

clear(string $name) deprecated

deprecated Use ->getResponseCookies()->clear() or $app->make(ResponseCookieJar::class)->clear()

No description

Parameters

string $name

Cookie[] getCookies() deprecated

deprecated Use ->getResponseCookies()->getCookies() or $app->make(ResponseCookieJar::class)->getCookies()

No description

Return Value

Cookie[]

protected Request getRequest()

Get the request for this cookie jar.

Return Value

Request