Cookie::set()
Set a new cookie
Cookie::set(string $key, string $value, array $options = [ ]): bool
Parameters
Name | Type | Default | Description |
---|---|---|---|
$keyrequired | string |
no default value | The name of the cookie |
$valuerequired | string |
no default value | The cookie content |
$options | array |
[ ]
|
Array of options: lifetime, path, domain, secure, httpOnly, sameSite |
Return type
bool
true: cookie was created, false: cookie creation failed
Parent class
Examples
// expires in 1 hour
Cookie::set('mycookie', 'hello', ['lifetime' => 60]);