Thanks for the reply,

I like the fact that you can get the individual values using this method.

So if needed this information to dynamically change a menu for example, I 
would need to put this into every Controller?, or App Controller to be 
available everywhere?

What would be the difference between putting this in beforeRender v 
beforeFilter?

Finally, I have been playing with $this->Session->read('Auth.User.id') in 
the view itself. What are the pros and cons of this approach?

It seems that there are several possible ways to do it, but what is the 
RIGHT way?

Thanks

On Tuesday, 16 September 2014 10:12:17 UTC+1, majna wrote:
>
> 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:
>>
>> 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 
>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fcakephp%2Fcakephp%2Fissues%2F3929&sa=D&sntz=1&usg=AFQjCNGHXaJlwIdSvjin9GJCB38XzvsWAw>
>>  
>> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to