OK, nevermind. Sure enough the second I post, I come up with a
solution (after struggling all morning on the problem).

class AppController extends Controller {
 var $auth_role;
}

then refer to it as $this->auth_role in all controllers.

On Apr 10, 11:16 am, qwanta <rgmic...@gmail.com> wrote:
> I am setting a variable value that in app_controller beforeFilter, and
> I would like to access it in all child controllers beforeFilter
> function.
>
> class AppController extends Controller {
>   var $components = array('Auth');
>   var $uses = array('User');
>
>   $auth_id =  $this->Auth->user('id');
>   if ( $auth_id ) {
>     $auth_role = $this->User->getRole($auth_id);
>   }
>
> }
>
> class XController extends AppController {
>   (...)
>   function beforeFIlter() {
>     parent::beforeFilter();
>     if ($auth_role == "calibrator") {
>        (...)
>     }
>   }
>
> }
>
> When I call a method in XController. I get an $auth_role not defined
> error. Is there a way to pass the variable value to the child
> controller?
> Thanks
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to