CookieComponent Class Info:
- Class Declaration:
- class CookieComponent extends Object
- File name:
- cake/libs/controller/components/cookie.php
- Summary:
- Cookie Component. Cookie handling for the controller.
- Class Inheritance
- package
- cake
- subpackage
- cake.cake.libs.controller.components
Properties:
Show/Hide parent properties
| public | domain | Domain path. The domain that the cookie is available. Overridden with the controller beforeFilter(); $this->Cookie->domain = '.example.com'; To make the cookie available on all subdomains of example.com. Set $this->Cookie->domain = '.example.com'; in your controller beforeFilter |
| protected | key | Encryption key. Overridden with the controller beforeFilter(); $this->Cookie->key = 'SomeRandomString'; |
| protected | _log | Log object |
| public | name | The name of the cookie. Overridden with the controller beforeFilter(); $this->Cookie->name = 'CookieName'; |
| public | path | Cookie path. Overridden with the controller beforeFilter(); $this->Cookie->path = '/'; The path on the server in which the cookie will be available on. If var $cookiePath is set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the entire domain. |
| public | secure | Secure HTTPS only cookie. Overridden with the controller beforeFilter(); $this->Cookie->secure = true; Indicates that the cookie should only be transmitted over a secure HTTPS connection. When set to true, the cookie will only be set if a secure connection exists. |
| public | time | The time a cookie will remain valid. Can be either integer Unix timestamp or a date string. Overridden with the controller beforeFilter(); $this->Cookie->time = '5 Days'; |
Method Summary:
Show/Hide parent methods
| public | cakeError( $method, $messages = array ( ) ) |
| public | __construct( ) |
| public | del( $key ) |
| public | destroy( ) |
| public | dispatchMethod( $method, $params = array ( ) ) |
| public | initialize( $controller, $settings ) |
| public | log( $msg, $type = 2 ) |
| public | Object( ) |
| protected | _persist( $name, $return, $object, $type = NULL ) |
| public | read( $key = NULL ) |
| public | requestAction( $url, $extra = array ( ) ) |
| protected | _savePersistent( $name, $object ) |
| protected | _set( $properties = array ( ) ) |
| public | startup( ) |
| public | _stop( $status = 0 ) |
| public | toString( ) |
| public | type( $type = 'cipher' ) |
| public | write( $key, $value = NULL, $encrypt = true, $expires = NULL ) |
cakeError
topUsed to report user friendly errors.
If there is a file app/error.php or app/app_error.php this file will be loaded
error.php is the AppError class it should extend ErrorHandler class.
- Parameters:
-
$method string Method to be called in the error class (AppError or ErrorHandler classes) required (no default) $messages array Message that is to be displayed by the error class optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 189
- return
- error message
- access
- public
__construct
topClass constructor, overridden in descendant classes.
- Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 63
del
topDelete a cookie value
Optional [Name.], reguired key
$this->Cookie->read('Name.key);
You must use this method before any output is sent to the browser.
Failure to do so will result in header already sent errors.
- Parameters:
-
$key string Key of the value to be deleted required (no default) - Method defined in class:
- CookieComponent
- Method defined in file:
- cake/libs/controller/components/cookie.php on line 274
- return
- void
- access
- public
destroy
topDestroy current cookie
You must use this method before any output is sent to the browser.
Failure to do so will result in header already sent errors.
- Method defined in class:
- CookieComponent
- Method defined in file:
- cake/libs/controller/components/cookie.php on line 305
- return
- void
- access
- public
dispatchMethod
topCalls a method on this object with the given parameters. Provides an OO wrapper
for call_user_func_array, and improves performance by using straight method calls
in most cases.
- Parameters:
-
$method string Name of the method to call required (no default) $params array Parameter list to use when calling $method optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 113
- return
- mixed Returns the result of the method call
- access
- public
initialize
topMain execution method.
- Parameters:
-
$controller object A reference to the instantiating controller object required (no default) $settings required (no default) - Method defined in class:
- CookieComponent
- Method defined in file:
- cake/libs/controller/components/cookie.php on line 159
- access
- public
log
topAPI for logging events.
- Parameters:
-
$msg string Log message required (no default) $type integer Error type constant. Defined in app/config/core.php. optional 2 - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 150
- return
- boolean Success of log write
- access
- public
Object
topA hack to support __construct() on PHP 4
Hint: descendant classes have no PHP4 class_name() constructors,
so this constructor gets called first and calls the top-layer __construct()
which (if present) should call parent::__construct()
- Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 53
- return
- Object
_persist
topChecks for a persistent class file, if found file is opened and true returned
If file is not found a file is created and false returned
If used in other locations of the model you should choose a unique name for the persistent file
There are many uses for this method, see manual for examples
- Parameters:
-
$name string name of the class to persist required (no default) $return required (no default) $object string the object to persist required (no default) $type optional NULL - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 219
- return
- boolean Success
- access
- protected
- todo
- add examples to manual
read
topRead the value of the $_COOKIE[$key];
Optional [Name.], reguired key
$this->Cookie->read(Name.key);
- Parameters:
-
$key mixed Key of the value to be obtained. If none specified, obtain map key => values optional NULL - Method defined in class:
- CookieComponent
- Method defined in file:
- cake/libs/controller/components/cookie.php on line 236
- return
- string or null, value for specified key
- access
- public
requestAction
topCalls a controller's method from any location.
- Parameters:
-
$url mixed String or array-based url. required (no default) $extra array if array includes the key "return" it sets the AutoRender to true. optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 86
- return
- mixed Boolean true or false on success/failure, or contents of rendered action if 'return' is set in $extra.
- access
- public
_savePersistent
topYou should choose a unique name for the persistent file
There are many uses for this method, see manual for examples
- Parameters:
-
$name string name used for object to cache required (no default) $object object the object to persist required (no default) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 247
- return
- boolean true on save, throws error if file can not be created
- access
- protected
_set
topAllows setting of multiple properties of the object in a single line of code.
- Parameters:
-
$properties array An associative array containing properties and corresponding values. optional array ( ) - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 169
- return
- void
- access
- protected
startup
topStart CookieComponent for use in the controller
- Method defined in class:
- CookieComponent
- Method defined in file:
- cake/libs/controller/components/cookie.php on line 168
- access
- public
_stop
topStop execution of the current script
- Parameters:
-
$status optional 0 - Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 139
- return
- void
- access
- public
toString
topObject-to-string conversion.
Each class can override this method as necessary.
- Method defined in class:
- Object
- Method defined in file:
- cake/libs/object.php on line 73
- return
- string The name of this class
- access
- public
type
topWill allow overriding default encryption method.
- Parameters:
-
$type string Encryption method optional 'cipher' - Method defined in class:
- CookieComponent
- Method defined in file:
- cake/libs/controller/components/cookie.php on line 328
- access
- public
- todo
- NOT IMPLEMENTED
write
topWrite a value to the $_COOKIE[$key];
Optional [Name.], reguired key, optional $value, optional $encrypt, optional $expires
$this->Cookie->write('[Name.]key, $value);
By default all values are encrypted.
You must pass $encrypt false to store values in clear test
You must use this method before any output is sent to the browser.
Failure to do so will result in header already sent errors.
- Parameters:
-
$key mixed Key for the value required (no default) $value mixed Value optional NULL $encrypt boolean Set to true to encrypt value, false otherwise optional true $expires string Can be either Unix timestamp, or date string optional NULL - Method defined in class:
- CookieComponent
- Method defined in file:
- cake/libs/controller/components/cookie.php on line 193
- access
- public