Get User data in default.ctp
I'm using Cake 2.3.5. I followed the Blog+Authentication tutorial on the
main website. I want to alter it so that a welcome message displays in the
header for all pages, so I need to get the username in default.ctp.
I have tried these methods:
<div>Signed in as: <?php echo AuthComponent::user('username'); ?></div>
<?php $user = $this->Session->read('Auth.User');
echo $user['username']; ?>
Both always return null, and nothing gets printed, even on pages where I
successfully get the username in a user view by setting a php variable in
UserController based on the id number that initiated the function.
How can I get the logged in users data in default.ctp?
No comments:
Post a Comment