Get current user from View
Posted
by
gosu kiwi
on Stack Overflow
See other posts from Stack Overflow
or by gosu kiwi
Published on 2012-09-16T02:33:04Z
Indexed on
2012/09/16
3:38 UTC
Read the original article
Hit count: 155
So what I want to do is, in my main layout, have a menu for logged in users, and a different for anon users.
THe layout will be used on every page, so I'm not sure how to do this, as I've seen, the Auth Component can only be used in the controller, this would be nice if I had to do this in only one view, but for every view, how can I do this? Do I have to do something on AppController?
What I want to do is basically
// layout
<?php if(logged): ?>
Welcome <?php echo $user; ?>
<?php else: ?>
Welcom anon, Log in?
<?php endif; ?>
© Stack Overflow or respective owner