This is documentation for Kohana v2.3.x.
Status | Draft |
---|---|
Todo | Comments and corrections |
Provides methods for working with COOKIE data.
Default settings for cookies are specified in application/config/cookie.php
. You may override
these settings by passing parameters to the helper.
''
(Use on localhost
). For site-wide cookies, prefix your domain with a period .example.com
'/'
0
(zero) seconds for a cookie which expires when the browser is closed. NOTE: time() will be added to this value, so be careful not to make expire too large.FALSE
.FALSE
. Note: Requires at least PHP version 5.2.0
cookie::set()
accepts multiple parameters, only the cookie name and value are required. You may pass parameters to this method as discrete values:
cookie::set($name, $value, $expire, $path, $domain, $secure, $httponly);
Or you may pass an associative array of values as a parameter:
$cookie_params = array( 'name' => 'Very_Important_Cookie', 'value' => 'Choclate Flavoured Mint Delight', 'expire' => '86500', 'domain' => '.example.com', 'path' => '/' ); cookie::set($cookie_params);
cookie::get()
accepts multiple parameters, Only the cookie name is required.
$cookie_value = cookie::get($cookie_name, $default_value = NULL, $xss_clean = FALSE);
Setting the third parameter to TRUE
will filter the cookie for unsafe data.
Returns $default_value
if the cookie item does not exist.
cookie::delete()
accepts multiple parameters, Only the cookie name is required. This method is identical cookie::set()
but sets the cookie value to ''
effectively deleting it.
cookie::delete('stale_cookie');