You can set a view variable in AppControler:
public function beforeRender() {
$this->set('auth', $this->Auth->user());
}
and use it in the view:
if ($auth) {
echo $auth['username'];
}
On Monday, September 15, 2014 6:53:32 PM UTC+2, Dave Edwards wrote:
-- public function beforeRender() {
$this->set('auth', $this->Auth->user());
}
and use it in the view:
if ($auth) {
echo $auth['username'];
}
On Monday, September 15, 2014 6:53:32 PM UTC+2, Dave Edwards wrote:
In CakePHP 3.x what is the correct way to establish whether the user is logged in via Auth in a view/template?I found this https://github.com/cakephp/cakephp/issues/3929 which suggests that methods available in 2.x have been removed?Do I need to check in each and every controller and set something for the view?Can an example be provided please?Dave
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment