-
Notifications
You must be signed in to change notification settings - Fork 24
globalauth
Tartoob edited this page Sep 16, 2017
·
1 revision
Since CakePHP 3.0 it's very hard to get the logged in user into your models, behaviors and other classes beside
controllers ($this->Auth->user()
).
The GlobalAuth-Component allows us to get the logged in user global.
You can load the component in your AppController
:
public function initialize() {
// code
$this->loadComponent('Utils.GlobalAuth');
}
Whenever you need data of the logged in user use the following code:
$user = Configure::read('GlobalAuth');
$user
will now contain an array with the data of the user.