Thank you ShadowCross,
I do some other test and I discover that if I call the function from
URL it works and the Security::cipher() and the Security.salt is set ,
but if I call the function from an other controller it doesn't work
and the  Security.salt  is set but the Security::cipher() is empty and
I don't understand Why...
I think that there is very strange!

Thank you
Bye

________________________
http://pcc8.netsons.org


On 12 Mar, 08:35, ShadowCross <[email protected]> wrote:
> In your UsersController, try adding the following lines BEFORE you
> execute $this->Cookie->write():
>
>   debug(Configure::read('Security.salt');
>   debug($this->Cookie->key);
>
> The first line displays the default key that the CookieComponent uses
> (usually defined in app/config/core.php), but the second line is the
> actual value that Security::cipher() actually tries to use.
>
> If both debug values are blank, check your code for places where
> Configure::write(Security.salt, ...) is being executed.  If the first
> debug value is not blank, but the second one is, check your
> AppController and UsersController if you are overriding the default
> value for $this->Cookie->key (either by using the
>
>   var $components    = array('Cookie' => array(...));
>
> syntax, or by
>
>   $this->Cookie->key = ...;
>
> On Mar 11, 2:12 am, Carachi <[email protected]> wrote:
>
>
>
>
>
>
>
> > 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

Reply via email to