Displaying logged-in user in header

I have no knowledge about ternary operator performance, but your solution was indeed what I meant by using CakePHP methodology. I stored this code in a variable such that the code doesn’t need to be inside the html.

However, I don’t understand why this works and does not result in the same error of Record not found in table "users" with primary key [NULL] since I thought this was due to the view($id=null) in UserController.php.

So I see from this that the current user and the Users functions can be accessed through controller (whereas $user is unknown). I made a new topic since I can’t apply similar access in the index View of Articles.