Cookie Helper¶
The Cookie Helper file contains functions that assist in working with cookies.
Available Functions¶
The following functions are available:
Parameters: - $name (mixed) – Cookie name or associative array of all of the parameters available to this function
- $value (string) – Cookie value
- $expire (int) – Number of seconds until expiration
- $domain (string) – Cookie domain (usually: .yourdomain.com)
- $path (string) – Cookie path
- $prefix (string) – Cookie name prefix
- $secure (bool) – Whether to only send the cookie through HTTPS
- $httponly (bool) – Whether to hide the cookie from JavaScript
Return type: void
This helper function gives you view file friendly syntax to set browser cookies. Refer to the Input Library for a description of its use, as this function is an alias for CI_Input::set_cookie().
Parameters: - $index (string) – Cookie name
- $xss_clean (bool) – Whether to apply XSS filtering to the returned value
Returns: The cookie value or NULL if not found
Return type: mixed
This helper function gives you view file friendly syntax to get browser cookies. Refer to the Input Library for a description of its use, as this function is an alias for CI_Input::cookie().
Parameters: - $name (string) – Cookie name
- $domain (string) – Cookie domain (usually: .yourdomain.com)
- $path (string) – Cookie path
- $prefix (string) – Cookie name prefix
Return type: void
Lets you delete a cookie. Unless you’ve set a custom path or other values, only the name of the cookie is needed.
delete_cookie('name');
This function is otherwise identical to set_cookie(), except that it does not have the value and expiration parameters. You can submit an array of values in the first parameter or you can set discrete parameters.
delete_cookie($name, $domain, $path, $prefix)