Constants

SAMESITE_LAX

SAMESITE_LAX = 'lax'

SAMESITE_STRICT

SAMESITE_STRICT = 'strict'

Properties

$name

$name : 

Type

$value

$value : 

Type

$domain

$domain : 

Type

$expire

$expire : 

Type

$path

$path : 

Type

$secure

$secure : 

Type

$httpOnly

$httpOnly : 

Type

$raw

$raw : 

Type

$sameSite

$sameSite : 

Type

Methods

fromString()

fromString(string  $cookie, boolean  $decode = false) : static

Creates cookie from raw header string.

Parameters

string $cookie
boolean $decode

Returns

static

__construct()

__construct(string  $name, string|null  $value = null, integer|string|\DateTimeInterface  $expire, string  $path = '/', string|null  $domain = null, boolean  $secure = false, boolean  $httpOnly = true, boolean  $raw = false, string|null  $sameSite = null) 

Parameters

string $name

The name of the cookie

string|null $value

The value of the cookie

integer|string|\DateTimeInterface $expire

The time the cookie expires

string $path

The path on the server in which the cookie will be available on

string|null $domain

The domain that the cookie is available to

boolean $secure

Whether the cookie should only be transmitted over a secure HTTPS connection from the client

boolean $httpOnly

Whether the cookie will be made accessible only through the HTTP protocol

boolean $raw

Whether the cookie value should be sent with no url encoding

string|null $sameSite

Whether the cookie will be available for cross-site requests

Throws

\InvalidArgumentException

__toString()

__toString() : string

Returns the cookie as a string.

Returns

string —

The cookie

getName()

getName() : string

Gets the name of the cookie.

Returns

string

getValue()

getValue() : string|null

Gets the value of the cookie.

Returns

string|null

getDomain()

getDomain() : string|null

Gets the domain that the cookie is available to.

Returns

string|null

getExpiresTime()

getExpiresTime() : integer

Gets the time the cookie expires.

Returns

integer

getMaxAge()

getMaxAge() : integer

Gets the max-age attribute.

Returns

integer

getPath()

getPath() : string

Gets the path on the server in which the cookie will be available on.

Returns

string

isSecure()

isSecure() : boolean

Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client.

Returns

boolean

isHttpOnly()

isHttpOnly() : boolean

Checks whether the cookie will be made accessible only through the HTTP protocol.

Returns

boolean

isCleared()

isCleared() : boolean

Whether this cookie is about to be cleared.

Returns

boolean

isRaw()

isRaw() : boolean

Checks if the cookie value should be sent with no url encoding.

Returns

boolean

getSameSite()

getSameSite() : string|null

Gets the SameSite attribute.

Returns

string|null