class Cookie (View source)

A set of static methods for manipulating cookies.

Traits

Provides extensions to this object to integrate it with standard config API methods.

Constants

SAMESITE_LAX

SAMESITE_STRICT

SAMESITE_NONE

Config options

report_errors bool
default_samesite string

Must be "Strict", "Lax", or "None"

Properties

Methods

public static 
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

public
mixed
uninherited(string $name)

Gets the uninherited value for the given config option

public static 
get_inst()

Fetch the current instance of the cookie backend.

public static 
set(string $name, mixed $value, float $expiry = 90, string $path = null, string $domain = null, bool $secure = false, bool $httpOnly = true)

Set a cookie variable.

public static 
null|string
get(string $name, bool $includeUnsent = true)

Get the cookie value by name. Returns null if not set.

public static 
array
get_all(bool $includeUnsent = true)

Get all the cookies.

public static 
force_expiry(string $name, null|string $path = null, null|string $domain = null, bool $secure = false, bool $httpOnly = true)

No description

public static 
void
validateSameSite(string $sameSite)

Validate if the samesite value for a cookie is valid for the current request.

Details

static Config_ForClass config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

Return Value

Config_ForClass

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

static Cookie_Backend get_inst()

Fetch the current instance of the cookie backend.

Return Value

Cookie_Backend

static set(string $name, mixed $value, float $expiry = 90, string $path = null, string $domain = null, bool $secure = false, bool $httpOnly = true)

Set a cookie variable.

Expiry time is set in days, and defaults to 90.

Parameters

string $name
mixed $value
float $expiry
string $path
string $domain
bool $secure
bool $httpOnly

See http://php.net/set_session

static null|string get(string $name, bool $includeUnsent = true)

Get the cookie value by name. Returns null if not set.

Parameters

string $name
bool $includeUnsent

Return Value

null|string

static array get_all(bool $includeUnsent = true)

Get all the cookies.

Parameters

bool $includeUnsent

Return Value

array

static force_expiry(string $name, null|string $path = null, null|string $domain = null, bool $secure = false, bool $httpOnly = true)

No description

Parameters

string $name
null|string $path
null|string $domain
bool $secure
bool $httpOnly

static void validateSameSite(string $sameSite)

Validate if the samesite value for a cookie is valid for the current request.

Logs a warning if the samesite value is "None" for a non-https request.

Parameters

string $sameSite

Return Value

void

Exceptions

LogicException