Re: Set user variables
is $this->Auth->user('id') really that difficult to call? --~--~-~--~~~---~--~~ 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: Set user variables
Why not just use $this->Auth->user('whatever')? AppController loads the Auth component, so any other controller can access it. Also, AppController::beforeFilter() will still run if you do not have beforeFilter() in your own controller. It will only *not* run if you override beforeFilter() in your controller and fail to call the parent's. So, there's no need to create your the method in a controller if only to ensure AppController's version will be run. It will run on its own. On Tue, Jul 28, 2009 at 12:09 PM, Dave Maharaj :: WidePixels.com wrote: > I have a set of variables that are used throughout the app such as > > $auth = $this->Auth->user('id'); > $slug = $this->Auth->user('slug'); > $role = $this->Auth->user('role'); > > and so on > > How can I define these in the app_controller beforeFilter so I can grab them > from any controller using > > function beforeFilter() > { > parent::beforeFilter(); > } > > or any other way that will work. > > thanks, > > Dave > > > --~--~-~--~~~---~--~~ 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: Set user variables
Thanks, Sounds good. Will give that a try. Dave -Original Message- From: tobi_one [mailto:tobias.h...@gmail.com] Sent: July-28-09 2:38 PM To: CakePHP Subject: Re: Set user variables What I do, is to define methods in the app_controller, just like: function userId() { return $this->Session->read('Auth.User.id'); } If you want to access the current userId in another controller then simply call $userid = $this->userId(); HTH Cheers, tobi_one On Jul 28, 6:09 pm, "Dave Maharaj :: WidePixels.com" wrote: > I have a set of variables that are used throughout the app such as > > $auth = $this->Auth->user('id'); > $slug = $this->Auth->user('slug'); > $role = $this->Auth->user('role'); > > and so on > > How can I define these in the app_controller beforeFilter so I can > grab them from any controller using > > function beforeFilter() > { > parent::beforeFilter(); > } > > or any other way that will work. > > thanks, > > Dave --~--~-~--~~~---~--~~ 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: Set user variables
What I do, is to define methods in the app_controller, just like: function userId() { return $this->Session->read('Auth.User.id'); } If you want to access the current userId in another controller then simply call $userid = $this->userId(); HTH Cheers, tobi_one On Jul 28, 6:09 pm, "Dave Maharaj :: WidePixels.com" wrote: > I have a set of variables that are used throughout the app such as > > $auth = $this->Auth->user('id'); > $slug = $this->Auth->user('slug'); > $role = $this->Auth->user('role'); > > and so on > > How can I define these in the app_controller beforeFilter so I can grab them > from any controller using > > function beforeFilter() > { > parent::beforeFilter(); > } > > or any other way that will work. > > thanks, > > Dave --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---