Re: Loading a cookie inside a model's constructor
But I need to access the cookie in the model because that model uses a dbconfig that relies in what the cookie is set to. On Oct 14, 4:15 pm, cricket zijn.digi...@gmail.com wrote: On Thu, Oct 14, 2010 at 4:38 PM, Raisen weys...@gmail.com wrote: So I want to read a cookie using the Cakephp's Cookie class. First, I tried to import only the cookie class and read the cookie, but I was getting an error stating that the cipher key cannot be null. So I imported the Configure class, set the key property of the cookie instance to the respective cipher key, but the cookie is returning a different result from what it's set to. Any ideas?\ The override constructor class looks like: class Member extends AppModel { function __construct( $id = false, $table = NULL, $ds = NULL ) { App::import('Component','Cookie'); App::import('Core','Configure'); $conf = new Configure(); $cookie = new CookieComponent(); $cookie-key = $conf-read(Security.cipherSeed); var_dump($cookie-read('sel_app')); ... parent::__construct($id,$table,$ds); You should read write to cookies in the controller (or component) not the model. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Loading a cookie inside a model's constructor
On Fri, Oct 15, 2010 at 9:56 PM, Raisen weys...@gmail.com wrote: But I need to access the cookie in the model because that model uses a dbconfig that relies in what the cookie is set to. Like said above pass the cookie from the controller to the model, in fact just pass the needed value from within the cookie to the model. If your model is dependent on a cookie then it is time to refactor :-) Cheers Tarique -- = Cheesecake-Photoblog: http://cheesecake-photoblog.org PHP for E-Biz: http://sanisoft.com = Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Loading a cookie inside a model's constructor
Thank you!! I was missing the initialize method. Also, I don't think I can pass from the controller because it needs to be set at the constructor method otherwise cake will thrown an exception saying that it cannot find the table. On Oct 14, 6:22 pm, Miles J mileswjohn...@gmail.com wrote: You should be passing the cookie from the controller to the model. $this-Model-cookie = $this-Cookie-read('cookieName'); But to answer your question, you need to initialize the cookie component. $cookie = new CookieComponent(); $cookie-initialize($this, array()); On Oct 14, 4:15 pm, cricket zijn.digi...@gmail.com wrote: On Thu, Oct 14, 2010 at 4:38 PM, Raisen weys...@gmail.com wrote: So I want to read a cookie using the Cakephp's Cookie class. First, I tried to import only the cookie class and read the cookie, but I was getting an error stating that the cipher key cannot be null. So I imported the Configure class, set the key property of the cookie instance to the respective cipher key, but the cookie is returning a different result from what it's set to. Any ideas?\ The override constructor class looks like: class Member extends AppModel { function __construct( $id = false, $table = NULL, $ds = NULL ) { App::import('Component','Cookie'); App::import('Core','Configure'); $conf = new Configure(); $cookie = new CookieComponent(); $cookie-key = $conf-read(Security.cipherSeed); var_dump($cookie-read('sel_app')); ... parent::__construct($id,$table,$ds); You should read write to cookies in the controller (or component) not the model. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Loading a cookie inside a model's constructor
Maybe... :) This model is a plugin model though, so it relies on the cookie set by the main application's controller to find out which database configuration to connect to. Thanks all for the replies, the code is working now. On Oct 15, 10:08 am, Dr. Tarique Sani tariques...@gmail.com wrote: On Fri, Oct 15, 2010 at 9:56 PM, Raisen weys...@gmail.com wrote: But I need to access the cookie in the model because that model uses a dbconfig that relies in what the cookie is set to. Like said above pass the cookie from the controller to the model, in fact just pass the needed value from within the cookie to the model. If your model is dependent on a cookie then it is time to refactor :-) Cheers Tarique -- = Cheesecake-Photoblog:http://cheesecake-photoblog.org PHP for E-Biz:http://sanisoft.com = Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Loading a cookie inside a model's constructor
So I want to read a cookie using the Cakephp's Cookie class. First, I tried to import only the cookie class and read the cookie, but I was getting an error stating that the cipher key cannot be null. So I imported the Configure class, set the key property of the cookie instance to the respective cipher key, but the cookie is returning a different result from what it's set to. Any ideas?\ The override constructor class looks like: class Member extends AppModel { function __construct( $id = false, $table = NULL, $ds = NULL ) { App::import('Component','Cookie'); App::import('Core','Configure'); $conf = new Configure(); $cookie = new CookieComponent(); $cookie-key = $conf-read(Security.cipherSeed); var_dump($cookie-read('sel_app')); ... parent::__construct($id,$table,$ds); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Loading a cookie inside a model's constructor
On Thu, Oct 14, 2010 at 4:38 PM, Raisen weys...@gmail.com wrote: So I want to read a cookie using the Cakephp's Cookie class. First, I tried to import only the cookie class and read the cookie, but I was getting an error stating that the cipher key cannot be null. So I imported the Configure class, set the key property of the cookie instance to the respective cipher key, but the cookie is returning a different result from what it's set to. Any ideas?\ The override constructor class looks like: class Member extends AppModel { function __construct( $id = false, $table = NULL, $ds = NULL ) { App::import('Component','Cookie'); App::import('Core','Configure'); $conf = new Configure(); $cookie = new CookieComponent(); $cookie-key = $conf-read(Security.cipherSeed); var_dump($cookie-read('sel_app')); ... parent::__construct($id,$table,$ds); You should read write to cookies in the controller (or component) not the model. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Loading a cookie inside a model's constructor
You should be passing the cookie from the controller to the model. $this-Model-cookie = $this-Cookie-read('cookieName'); But to answer your question, you need to initialize the cookie component. $cookie = new CookieComponent(); $cookie-initialize($this, array()); On Oct 14, 4:15 pm, cricket zijn.digi...@gmail.com wrote: On Thu, Oct 14, 2010 at 4:38 PM, Raisen weys...@gmail.com wrote: So I want to read a cookie using the Cakephp's Cookie class. First, I tried to import only the cookie class and read the cookie, but I was getting an error stating that the cipher key cannot be null. So I imported the Configure class, set the key property of the cookie instance to the respective cipher key, but the cookie is returning a different result from what it's set to. Any ideas?\ The override constructor class looks like: class Member extends AppModel { function __construct( $id = false, $table = NULL, $ds = NULL ) { App::import('Component','Cookie'); App::import('Core','Configure'); $conf = new Configure(); $cookie = new CookieComponent(); $cookie-key = $conf-read(Security.cipherSeed); var_dump($cookie-read('sel_app')); ... parent::__construct($id,$table,$ds); You should read write to cookies in the controller (or component) not the model. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en