Thanks for the info guys. Basically the idea is a User has a preference represented by a field in the table 'display' and they can select it as an option so in the site to either display or not display their information. Its only used in 1 controller but will try them out and see what works best.
Thanks, Dave -----Original Message----- From: O.J. Tibi [mailto:[email protected]] Sent: October-16-09 3:20 AM To: CakePHP Subject: Re: beforeRender / filter On that point, may what you want to do is declare $display as a class member (just inside your controller class, not inside a method/action/ callback) like so: var $_display; and when you need to set it: $this->_display = $this->Auth->user('display'); Take note I used the Auth component as it is more concise and fits the purpose of the code. Now, if you want to get or test its value: if ($this->_display) { // do something here } Cheers, OJ On Oct 16, 12:55 pm, Miles J <[email protected]> wrote: > You cant set a variable within a function and expect it to be usable > again somewhere else. Variables defined in functions are restricted to > the functions scope. You have to set it to the object. > > $this->display = $this->Session->read('Auth.User.display'); > > On Oct 15, 8:20 pm, "Dave Maharaj :: WidePixels.com" > > <[email protected]> wrote: > > How can i access session data in beforeRender or before Filter? > > > i have $display = $this->Session->read('Auth.User.display'); > > > and i have that all over the controller. Is there a way i can define > > that in a before function and access it from there instead of that > > long snip allover? > > > I tried > > > function beforeRender() { > > > $display = $this->Session->read('Auth.User.display'); > > > } > > > or > > > function beforeFilter() { > > > $display = $this->Session->read('Auth.User.display'); > > > } > > > and in the controller $display comes up invalid variable > > > Dave --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
