I am using cookie helper in cakephp and i am using following code for accessing the value of cookie variable
$this->Cookie->write('testvar','testvalue');
I have made a helper class when i try to get the value of this cookie variable vid a following
$this->Cookie->read('testvar');
It produces an error(Call to a member function read() on a non-object).
Is there any other method by which i can access the cookie variable in helper.Although i can try the $_Cookie (server variable).
Your helper should looks like:
You can use it in your view like:
Don’t forget to include
MyCookiehelper in your controller;