in this i write the cookie value in controller file. i wanna read that cookie value in view file than how it possible.
After all CakePHP is a PHP framework, you can read them by $_COOKIE :)
Bear in mind that you should use:
$this->Cookie->write('myValue', $value, false);
in your controller, because otherwise it will be encrypted and it will be hard to use :)
Use Cookie components in AppController:
$components = array('Cookie');
Define following in AppController's beforeFilter():
$this->set('cookieHelper', $this->Cookie);
So that you could use it in view:
$cookieHelper->read('something');
You must read it in the controller and set the value to make it available to the view:
$this->set('myValue', $this->Cookie->read('cookieValue'));
Then in the view, you can access the variable $myValue to return the value of 'cookieValue':
<?php echo $myValue; ?>
I use the SessionComponent and SessionHelper to do this:
In the controller:
$this->Session->write('first_visit', true);
In the view:
if ($session->check('first_visit')) {
$session->del('first_visit');
echo $this->element('quick_intro');
}
You can also use $session->read('value') to read out a value from the session, instead of just checking if it exists.