get($name = null, $default = null)
The get method allows you to read a $_COOKIE variable. If no name given, all cookies are returned.
Static | Yes | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
|||||||||
Returns | mixed | |||||||||
Example |
|
The cookie class allows you to get, set and delete cookies.
The cookie class is configured through the global application configuration file, app/config/config.php. It defines a section called 'cookie', in which the following settings are defined:
Variable | Type | Default | Description |
---|---|---|---|
expiration | integer |
|
Number of seconds before the cookie expires. This value will be used when $expiration is not specified when you call the set() method. |
path | string |
|
Restrict the path that the cookie is available to. This value will be used when $path is not specified when you call the set() method. |
domain | string |
|
Restrict the domain that the cookie is available to. This value will be used when $domain is not specified when you call the set() method. |
secure | boolean |
|
Set to true if you only want to transmit cookies over secure connections. |
httponly | boolean |
|
Allow only transmit of cookies over HTTP, disabling Javascript access. |
If one or more of these values are missing from the global configuration, the class will use the defaults as defined in this table.
The get method allows you to read a $_COOKIE variable. If no name given, all cookies are returned.
Static | Yes | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
|||||||||
Returns | mixed | |||||||||
Example |
|
The set method allows you to create a cookie.
Static | Yes | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||||||||||||||
Returns | boolean | ||||||||||||||||||||||||
Example |
|
For every parameter not specified or defined as null, the globally defined configuration value will be substituted.
The delete method deletes a parameter from the $_COOKIE array.
When a cookie was created under a specified path or/or domain etc. you must also supply this to the delete function.
Static | Yes | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||||||||
Returns | void | ||||||||||||||||||
Example |
|