How do I print the username using session in cakephp?

cakephp, php, session

Solution

In your code you are setting $user with the content of the username. But you are not printing it.

<h1>Users Home</h1>
Welcome <?=$this->Session->read('Auth.User.username')?>

which is short for

<h1>Users Home</h1>
Welcome <?php print $this->Session->read('Auth.User.username'); ?>

Problem

I cannot get my username to show on the website when I call it form the session. The code on the index page is: ``` <h1>Users Home</h1> Welcome <?php $user = $this->Session->read('Users.username');?> ``` What am I doing wrong? I've also tried various other ways of calling it and then getting different error messages.

Original source

Related problems