- Full name:
\App\Infrastructure\Services\NativePhpCookies - This class is marked as final and can't be subclassed
- This class is a Final class
Methods
factory
- This method is static.
token
Generates a random token which is then hashed.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$length |
int |
set
Sets a regular cookie
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key |
mixed | |
$value |
mixed | |
$expires |
int|null |
Throws:
get
Retrieves a regular cookie if it is set.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string |
Return Value:
Returns cookie if valid
setSecureCookie
Set a secure cookie that is saved to the server.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$data |
array |
Throws:
getSecureCookie
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key |
mixed |
remove
Unset the cookie
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key |
mixed |
Throws:
buildCookie
Generates a hardened cookie string with digest.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$data |
mixed | Cookie value: e.g. random token or hash |
$expires |
mixed |
getCookieVars
Extracts data from the cookie string.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string | |
$str |
mixed |
getCookieData
Extracts the data from the cookie string.
This does not verify the cookie! This is just so you can get the token.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key |
mixed |
Return Value:
Cookie data var
verifySecureCookie
Verifies the expiry and MAC for the cookie
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key |
string | String from the client |