Cookie class
Framework\HTTP\Cookie
Class Cookie.
Implements:
Stringable
Defined in libraries/http/src/Cookie.php
Properties #
$domain
protected ?string $domain = NULL
$expires
protected ?DateTime $expires = NULL
$httpOnly
protected bool $httpOnly = false
$name
protected string $name
$path
protected ?string $path = NULL
$sameSite
protected ?string $sameSite = NULL
$secure
protected bool $secure = false
$value
protected string $value
Methods #
- __construct()
- Cookie constructor.
- __toString()
- -
- create()
- Create Cookie objects from a Cookie Header line.
- getDomain()
- -
- getExpires()
- -
- getName()
- -
- getPath()
- -
- getSameSite()
- -
- getValue()
- -
- isExpired()
- -
- isHttpOnly()
- -
- isSecure()
- -
- parse()
- Parses a Set-Cookie Header line and creates a new Cookie object.
- send()
- -
- setDomain()
- -
- setExpires()
- -
- setHttpOnly()
- -
- setPath()
- -
- setSameSite()
- -
- setSecure()
- -
- setValue()
- -
- toString()
- -
- makeArgumentValue()
- -
- setName()
- -
- trimmedOrNull()
- -
__construct()
public function __construct(string $name, string $value)
Cookie constructor.
Parameters
- string $name
- string $value
__toString()
public function __toString(): string
Returns
string
create()
public static function create(string $line): array
Create Cookie objects from a Cookie Header line.
Parameters
- string $line
Returns
array
getDomain()
public function getDomain(): ?string
Returns
?string
getExpires()
public function getExpires(): ?DateTime
Returns
?DateTime
getName()
public function getName(): string
Returns
string
getPath()
public function getPath(): ?string
Returns
?string
getSameSite()
public function getSameSite(): ?string
Returns
?string
getValue()
public function getValue(): string
Returns
string
isExpired()
public function isExpired(): bool
Returns
bool
isHttpOnly()
public function isHttpOnly(): bool
Returns
bool
isSecure()
public function isSecure(): bool
Returns
bool
parse()
public static function parse(string $line): ?\Framework\HTTP\Cookie
Parses a Set-Cookie Header line and creates a new Cookie object.
Parameters
- string $line
Returns
?\Framework\HTTP\Cookie
send()
public function send(): bool
Returns
bool
setDomain()
public function setDomain(?string $domain): static
Parameters
- ?string $domain
Returns
static
setExpires()
public function setExpires(DateTime|string|int|null $expires): static
Parameters
- DateTime|string|int|null $expires
Returns
static
setHttpOnly()
public function setHttpOnly(bool $httpOnly = true): static
Parameters
- bool $httpOnly
Returns
static
setPath()
public function setPath(?string $path): static
Parameters
- ?string $path
Returns
static
setSameSite()
public function setSameSite(?string $sameSite): static
Parameters
- ?string $sameSite - Strict, Lax, Unset or None
Returns
static
setSecure()
public function setSecure(bool $secure = true): static
Parameters
- bool $secure
Returns
static
setValue()
public function setValue(string $value): static
Parameters
- string $value
Returns
static
toString()
public function toString(): string
Returns
string
makeArgumentValue()
protected static function makeArgumentValue(string $part): array
Parameters
- string $part
Returns
array
setName()
protected function setName(string $name): static
Parameters
- string $name
Returns
static
trimmedOrNull()
protected static function trimmedOrNull(string $value): ?string
Parameters
- string $value
Returns
?string