Tuesday, July 28, 2009

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<dave@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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: