Can I see a copy of the login page? The only cause I can think of would be if the login page isn't setting the UserName session variable correctly.
You can test that theory. Add this to line 19 of the account.php page:
var_dump($_SESSION);
die();
See if there is a session variable for UserName set and if it is set to the value you expect.