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
-~----------~----~----~----~------~----~------~--~---