Cookie Component.
Provides enhanced cookie handling features for use in the controller layer. In addition to the basic features offered be Cake\Network\Response, this class lets you:
Cake\Controller\Component\CookieComponent uses Cake\Utility\CookieCryptTrait _delete( string $name )
Sets a cookie expire time to remove cookie value.
This is only done once all values in a cookie key have been removed with delete.
$name _getCookieEncryptionKey( )
Returns the encryption key to be used.
string_load( string|array $key )
Load the cookie data from the request and response objects.
Based on the configuration data, cookies will be decrypted. When cookies contain array data, that data will be expanded.
$key _write( string $name , string $value )
Set cookie
$name $value check( string|null $key null )
Returns true if given key is set in the cookie.
$key optional null booleanconfigKey( string $keyname , null|string|array $option null , string|null $value null )
Set the configuration for a specific top level key.
Set a single config option for a key:
$this->Cookie->configKey('User', 'expires', '+3 months');
Set multiple options:
$this->Cookie->configKey('User', [ 'expires', '+3 months', 'httpOnly' => true, ]);
$keyname $option optional null $value optional null array|nulldelete( string $key )
Delete a cookie value
You must use this method before any output is sent to the browser. Failure to do so will result in header already sent errors.
Deleting a top level key will delete all keys nested within that key. For example deleting the User key, will also delete User.email.
$key implementedEvents( )
Events supported by this component.
arrayCake\Controller\Component::implementedEvents() initialize( array $config )
Initialize config data and properties.
$config Cake\Controller\Component::initialize() read( string|null $key null )
Read the value of key path from request cookies.
This method will also allow you to read cookies that have been written in this request, but not yet sent to the client.
$key optional null stringwrite( string|array $key , mixed $value null )
Write a value to the response cookies.
You must use this method before any output is sent to the browser. Failure to do so will result in header already sent errors.
$key $value optional null __construct( Cake\Controller\ComponentRegistry $registry , array $config [] )
Constructor
Cake\Controller\ComponentRegistry $registry $config optional [] __debugInfo( )
Returns an array that can be used to describe the internal state of this object.
array__get( string $name )
Magic method for lazy loading $components.
$name mixed_checkCipher( string $encrypt )
Helper method for validating encryption cipher names.
$encrypt RuntimeException_decode( string $value , string|false $encrypt )
Decodes and decrypts a single value.
$value $encrypt string_decrypt( array $values , string|boolean $mode )
Decrypts $value using public $type method in Security class
$values $mode string_encrypt( string $value , string|boolean $encrypt , string|null $key null )
Encrypts $value using public $type method in Security class
$value $encrypt $key optional null string_explode( string $string )
Explode method to return array from string set in CookieComponent::_implode() Maintains reading backwards compatibility with 1.x CookieComponent::_implode().
$string array_implode( array $array )
Implode method to keep keys are multidimensional arrays
$array string_configDelete( string $key )
Delete a single config key
$key Cake\Core\Exception\Exception_configRead( string|null $key )
Read a config variable
$key mixed_configWrite( string|array $key , mixed $value , boolean|string $merge false )
Write a config variable
$key $value $merge optional false Cake\Core\Exception\Exceptionconfig( string|array|null $key null , mixed|null $value null , boolean $merge true )
Reading the whole config:
$this->config();
Reading a specific value:
$this->config('key');
Reading a nested value:
$this->config('some.nested.key');
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
$key optional null $value optional null $merge optional true mixedCake\Core\Exception\ExceptionconfigShallow( string|array $key , mixed|null $value null )
Merge provided config with existing config. Unlike config() which does a recursive merge for nested keys, this method does a simple merge.
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
$key $value optional null mixedlog( mixed $msg , integer|string $level LogLevel::ERROR , string|array $context [] )
Convenience method to write a message to Log. See Log::write() for more information on writing to logs.
$msg $level optional LogLevel::ERROR $context optional [] booleanprotected array
A component lookup table used to lazy load component objects.
[]
protected Cake\Controller\ComponentRegistry
Component registry class used to lazy load components.
protected boolean
Whether the config property has already been configured with defaults
false
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/3.1/class-Cake.Controller.Component.CookieComponent.html