Cakephp Classroom image

osdyui
 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91|
Lessons:-Core Libraries

$this->Cookie->name = ’baker_id’;
$this->Cookie->time = 3600; // or ’1 hour’
$this->Cookie->path = ’/bakers/preferences/’;
$this->Cookie->domain = ’example.com’;
$this->Cookie->secure = true; // i.e. only sent if using secure HTTPS
$this->Cookie->key = ’qSI232qs*&sXOw!adre@34SAv!@*(XSL#$%)asGb$@11~_+!@#HKis~#^’;
$this->Cookie->httpOnly = true;
}
Next, let’s look at how to use the different methods of the Cookie Component.
Using the Component
The CookieComponent offers a number of methods for working with Cookies.
CookieComponent::write(mixed $key, mixed $value = null, boolean $encrypt = true, mixed
$expires = null)
The write() method is the heart of cookie component, $key is the cookie variable name you want, and
the $value is the information to be stored:
$this->Cookie->write(’name’, ’Larry’);
You can also group your variables by supplying dot notation in the key parameter:
$this->Cookie->write(’User.name’, ’Larry’);
$this->Cookie->write(’User.role’, ’Lead’);
If you want to write more than one value to the cookie at a time, you can pass an array:
$this->Cookie->write(’User’,
array(’name’ => ’Larry’, ’role’ => ’Lead’)
);
All values in the cookie are encrypted by default. If you want to store the values as plain-text, set the
third parameter of the write() method to false. The encryption performed on cookie values is fairly
uncomplicated encryption system. It uses Security.salt and a predefined Configure class var
Security.cipherSeed to encrypt values. To make your cookies more secure you should change
Security.cipherSeed in app/Config/core.php to ensure a better encryption.:
$this->Cookie->write(’name’, ’Larry’, false);
The last parameter to write is $expires – the number of seconds before your cookie will expire. For
convenience, this parameter can also be passed as a string that the php strtotime() function understands:
// Both cookies expire in one hour.
$this->Cookie->write(’first_name’, ’Larry’, false, 3600);
$this->Cookie->write(’last_name’, ’Masters’, false, ’1 hour’);
CookieComponent::read(mixed $key = null)
This method is used to read the value of a cookie variable with the name specified by $key.:

 
 
 

osdyui

Skills    Cakephp

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)