Hi cricket,
I do this:
class UsersController extends AppController {
var $name = 'Users';
var $helper = array('Html','Form');
var $components = array('Cookie');
function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow(array('login','build_acl'));
}
function getUserFromCookies() {
$name = 'user';
debug($name); //print user
$this->Cookie->write($name, 'test' ,true); //print Warning
(512):
You cannot use an empty key for Security::cipher()
$user = $this->Cookie->read($name); //print Warning (512):
You
cannot use an empty key for Security::cipher()
return;
}
}
in the other controller I use this functions to write and read
function setCookies($name, $value, $time = NULL) {
$this->Cookie->write($name, $value ,true, $time);
return;
}
function getCookies($name) {
return $this->Cookie->read($name);
}
and this works!
I don't understand why in the UsersController it doesn't works!
Thank you
bye
On 10 Mar, 23:06, cricket <[email protected]> wrote:
> On Thu, Mar 10, 2011 at 4:48 PM, Carachi <[email protected]> wrote:
> > Thank you.
> > after set I call this method:
> > $this->Cookie->read('mycookie');
> > and it return this error:
> > Warning (512): You cannot use an empty key for
> > Security::cipher()
> > if I call with debug function so:
> > debug($this->Cookie->read('mycookie'));
> > doesn't return anything...
>
> No, we mean did you debug($name) to see that it's correct. In your
> latest example, though, you're using a literal string. So, now you
> need to ensure that $name == 'mycookie' in controller1.
>
> Perhaps a quicker way to handle this would be:
>
> $this->log($name);
> $this->Cookie->write($name, $value ,true, $time);
>
> other controller:
> $this->log($name);
> $this->Cookie->read($name);
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php