FileAccess Orion

Cookie
in package

Represents a cookie.

Tags
author

Johannes M. Schmitt schmittjoh@gmail.com

Table of Contents

SAMESITE_LAX  = 'lax'
SAMESITE_NONE  = 'none'
SAMESITE_STRICT  = 'strict'
$domain  : mixed
$expire  : mixed
$httpOnly  : mixed
$name  : mixed
$path  : mixed
$secure  : mixed
$value  : mixed
$raw  : mixed
$reservedCharsFrom  : mixed
$reservedCharsList  : mixed
$reservedCharsTo  : mixed
$sameSite  : mixed
$secureDefault  : mixed
__construct()  : mixed
__toString()  : string
Returns the cookie as a string.
create()  : self
fromString()  : static
Creates cookie from raw header string.
getDomain()  : string|null
Gets the domain that the cookie is available to.
getExpiresTime()  : int
Gets the time the cookie expires.
getMaxAge()  : int
Gets the max-age attribute.
getName()  : string
Gets the name of the cookie.
getPath()  : string
Gets the path on the server in which the cookie will be available on.
getSameSite()  : string|null
Gets the SameSite attribute.
getValue()  : string|null
Gets the value of the cookie.
isCleared()  : bool
Whether this cookie is about to be cleared.
isHttpOnly()  : bool
Checks whether the cookie will be made accessible only through the HTTP protocol.
isRaw()  : bool
Checks if the cookie value should be sent with no url encoding.
isSecure()  : bool
Checks whether the cookie should only be transmitted over a secure HTTPS connection from the client.
setSecureDefault()  : void

Constants

SAMESITE_LAX

public mixed SAMESITE_LAX = 'lax'

SAMESITE_NONE

public mixed SAMESITE_NONE = 'none'

SAMESITE_STRICT

public mixed SAMESITE_STRICT = 'strict'

Properties

$httpOnly

protected mixed $httpOnly

$reservedCharsFrom

private static mixed $reservedCharsFrom = ['=', ',', ';', ' ', "\t", "\r", "\n", "\v", "\f"]

$reservedCharsList

private static mixed $reservedCharsList = "=,; \t\r\n\v\f"

$reservedCharsTo

private static mixed $reservedCharsTo = ['%3D', '%2C', '%3B', '%20', '%09', '%0D', '%0A', '%0B', '%0C']

$sameSite

private mixed $sameSite

$secureDefault

private mixed $secureDefault = false

Methods

__construct()

public __construct(string $name[, string|null $value = null ], int|string|DateTimeInterface $expire[, string $path = '/' ][, string|null $domain = null ][, bool|null $secure = false ][, bool $httpOnly = true ][, bool $raw = false ][, string|null $sameSite = null ]) : mixed
Parameters
$name : string

The name of the cookie

$value : string|null = null

The value of the cookie

$expire : int|string|DateTimeInterface

The time the cookie expires

$path : string = '/'

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

$domain : string|null = null

The domain that the cookie is available to

$secure : bool|null = false

Whether the client should send back the cookie only over HTTPS or null to auto-enable this when the request is already using HTTPS

$httpOnly : bool = true

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

$raw : bool = false

Whether the cookie value should be sent with no url encoding

$sameSite : string|null = null

Whether the cookie will be available for cross-site requests

Tags
throws
InvalidArgumentException
Return values
mixed

__toString()

Returns the cookie as a string.

public __toString() : string
Return values
string

The cookie

create()

public static create(string $name[, string $value = null ], mixed $expire[, string|null $path = '/' ][, string $domain = null ][, bool $secure = null ][, bool $httpOnly = true ][, bool $raw = false ][, string|null $sameSite = self::SAMESITE_LAX ]) : self
Parameters
$name : string
$value : string = null
$expire : mixed
$path : string|null = '/'
$domain : string = null
$secure : bool = null
$httpOnly : bool = true
$raw : bool = false
$sameSite : string|null = self::SAMESITE_LAX
Return values
self

fromString()

Creates cookie from raw header string.

public static fromString(string $cookie[, bool $decode = false ]) : static
Parameters
$cookie : string
$decode : bool = false
Return values
static

getDomain()

Gets the domain that the cookie is available to.

public getDomain() : string|null
Return values
string|null

getExpiresTime()

Gets the time the cookie expires.

public getExpiresTime() : int
Return values
int

getMaxAge()

Gets the max-age attribute.

public getMaxAge() : int
Return values
int

getName()

Gets the name of the cookie.

public getName() : string
Return values
string

getPath()

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

public getPath() : string
Return values
string

getSameSite()

Gets the SameSite attribute.

public getSameSite() : string|null
Return values
string|null

getValue()

Gets the value of the cookie.

public getValue() : string|null
Return values
string|null

isCleared()

Whether this cookie is about to be cleared.

public isCleared() : bool
Return values
bool

isHttpOnly()

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

public isHttpOnly() : bool
Return values
bool

isRaw()

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

public isRaw() : bool
Return values
bool

isSecure()

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

public isSecure() : bool
Return values
bool

setSecureDefault()

public setSecureDefault(bool $default) : void
Parameters
$default : bool

The default value of the "secure" flag when it is set to null

Return values
void

Search results