Cookie
in package
Easy read/write of cookies.
Tags
Table of Contents
Methods
- delete() : bool
- Delete a cookie.
- exists() : bool
- Check if the specified cookie exists.
- get() : mixed
- Return the value of the specified cookie.
- put() : bool
- Create a new cookie.
Methods
delete()
Delete a cookie.
public
static delete(string $name) : bool
Parameters
- $name : string
-
Name of cookie to delete
Return values
boolexists()
Check if the specified cookie exists.
public
static exists(string $name) : bool
Parameters
- $name : string
-
Name of cookie to check
Return values
bool —Whether this cookie exists or not.
get()
Return the value of the specified cookie.
public
static get(string $name) : mixed
Parameters
- $name : string
-
Name of cookie to get the value of
Return values
mixed —Value of the cookie or an empty string if it doesn't exist
put()
Create a new cookie.
public
static put(string $name, string $value, int|null $expiry[, bool|null $secure = false ][, bool|null $httpOnly = false ][, bool|null $addExpiry = true ]) : bool
Parameters
- $name : string
-
Name of cookie to create.
- $value : string
-
Value to store in cookie.
- $expiry : int|null
-
When does the cookie expire? Null for session
- $secure : bool|null = false
-
Create as secure cookie?
- $httpOnly : bool|null = false
-
Create as httpOnly cookie?
- $addExpiry : bool|null = true
-
Whether to add expiry onto current timestamp or not.
Return values
bool —Whether cookie was set or not