Aplus Framework Docs

Cookie
in package
implements Stringable

Class Cookie.

Tags
see
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
see
https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
see
https://datatracker.ietf.org/doc/html/rfc6265
see
https://www.php.net/manual/en/function.setcookie.php

Interfaces, Classes, Traits and Enums

Stringable

Table of Contents

$domain  : string|null
$expires  : DateTime|null
$httpOnly  : bool
$name  : string
$path  : string|null
$sameSite  : string|null
$secure  : bool
$value  : string
__construct()  : mixed
Cookie constructor.
__toString()  : string
create()  : array<string, Cookie>
Create Cookie objects from a Cookie Header line.
getAsString()  : string
getDomain()  : string|null
getExpires()  : DateTime|null
getName()  : string
getPath()  : string|null
getSameSite()  : string|null
getValue()  : string
isExpired()  : bool
isHttpOnly()  : bool
isSecure()  : bool
parse()  : Cookie|null
Parses a Set-Cookie Header line and creates a new Cookie object.
send()  : bool
setDomain()  : static
setExpires()  : static
setHttpOnly()  : static
setPath()  : static
setSameSite()  : static
setSecure()  : static
setValue()  : static
toString()  : string
makeArgumentValue()  : array<int, string|null>
setName()  : static
trimmedOrNull()  : string|null

Properties

$domain

protected string|null $domain = null

$expires

protected DateTime|null $expires = null

$httpOnly

protected bool $httpOnly = false

$path

protected string|null $path = null

$sameSite

protected string|null $sameSite = null

$secure

protected bool $secure = false

Methods

__construct()

Cookie constructor.

public __construct(string $name, string $value) : mixed
Parameters
$name : string
$value : string
Return values
mixed

__toString()

public __toString() : string
Return values
string

create()

Create Cookie objects from a Cookie Header line.

public static create(string $line) : array<string, Cookie>
Parameters
$line : string
Return values
array<string, Cookie>

getAsString()

public getAsString() : string
Tags
deprecated

Use Cookie::toString()

codeCoverageIgnore
Return values
string

getDomain()

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

getExpires()

public getExpires() : DateTime|null
Return values
DateTime|null

getName()

public getName() : string
Return values
string

getPath()

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

getSameSite()

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

getValue()

public getValue() : string
Return values
string

isExpired()

public isExpired() : bool
Return values
bool

isHttpOnly()

public isHttpOnly() : bool
Return values
bool

isSecure()

public isSecure() : bool
Return values
bool

parse()

Parses a Set-Cookie Header line and creates a new Cookie object.

public static parse(string $line) : Cookie|null
Parameters
$line : string
Tags
throws
Exception

if setExpires fail

Return values
Cookie|null

send()

public send() : bool
Return values
bool

setDomain()

public setDomain(string|null $domain) : static
Parameters
$domain : string|null
Return values
static

setExpires()

public setExpires(DateTime|int|string|null $expires) : static
Parameters
$expires : DateTime|int|string|null
Tags
throws
Exception

if can not create from format

Return values
static

setHttpOnly()

public setHttpOnly([bool $httpOnly = true ]) : static
Parameters
$httpOnly : bool = true
Return values
static

setPath()

public setPath(string|null $path) : static
Parameters
$path : string|null
Return values
static

setSameSite()

public setSameSite(string|null $sameSite) : static
Parameters
$sameSite : string|null

Strict, Lax, Unset or None

Tags
throws
InvalidArgumentException

for invalid $sameSite value

Return values
static

setSecure()

public setSecure([bool $secure = true ]) : static
Parameters
$secure : bool = true
Return values
static

setValue()

public setValue(string $value) : static
Parameters
$value : string
Return values
static

toString()

public toString() : string
Tags
since
5.3
Return values
string

makeArgumentValue()

protected static makeArgumentValue(string $part) : array<int, string|null>
Parameters
$part : string
Return values
array<int, string|null>

setName()

protected setName(string $name) : static
Parameters
$name : string
Return values
static

trimmedOrNull()

protected static trimmedOrNull(string $value) : string|null
Parameters
$value : string
Return values
string|null

Search results