I am using PHP and Smarty. I have a simple application that:
- Shows page header
- Checks if user is logged in -> check session
- Checks if user wants to log out -> then clear session
- If logged in shows a menu.
- If not logged in, then challenges user for id/password -> set session
- Shows page footer
Now I want to add the following to header:
- username if logged in
- "login" string if not logged in
To do this seems to require the placement of my PrintHeader function to become complicated. I now cannot print header, until I know if user is logged in/just logged in/has logged out, plus header has to go before user/password challenge.
What approach can I use here? Is it possible to buffer a "not logged in" header, then replace it with "logged if header" if required.
SmartyApp::PrintHeader();
Application->IsLoggedIn()
Application->DoesUserWantsToLogOut()
Application->IfNotLoggedInThenShowChallengeToUser()
Application->IfLoggedInThenShowFullMenu()
SmartyApp::PrintFooter();