Reputation: 2025
in controller i try this, and print $cookieee,its give me array
$this->Cookie->write('User', $cookie, true, '+2 weeks');
$cookieee = $this->Cookie->read('User')
echo "<pre>";
print_r($cookieee);
echo "</pre>";
but My question
i try to print it by using below
echo "<pre>";
print_r($cookie);
echo "</pre>";
echo $cookie['username']."=cokie=";
and
$cookieee = $this->Cookie->read('User');
echo "<pre>";
print_r($cookieee);
echo "</pre>";
Upvotes: 1
Views: 1907
Reputation: 15579
your view does not have access to the cookie.. Basically $this is referring to two different things in the case of your controller and your view.. thus basically set it in a model that is passed to the view i.e viewmodel and then use that in your view.
Not famililar with PHP hence no code but this is my understanding based on using MVC framework in .NEt
I guess this question tells you how to do the same in PHP: how to read cookie value in cakephp view file
and if you want to break the MVC pattern here you could use: $_COOKIE[<cookie_name>]
.
Upvotes: 3
Reputation: 183
There is no Cookie helper in CakePHP, neither a method to access it in View.
You might want to set the cookie to a variable in controller, and then access that variable in corresponding view.
Upvotes: 2