This should work, so I'm really perplexed about why it's not working.
I'm checking to see if a user is logged in using a $session class method at the top of each admin page. However, I want to dynamically adjust the header file depending on whether a user is logged in, and on what role level that user has.
So I check $session->is_logged_in()
and then I went ahead and defined a variable called $logged = true
; to use later. I then use a $user->find_by_id($session->id)
method to create a new User object and store $user->role_level
in a new var called $role_level
for easy use.
This is all happening near the top of the page. Further down the page past form processing, etc., is the include("../_layouts/header.php")
command. Then, in the header.php file, I use little checks like if(!$logged) { ... } else { ... }
. However...
I am getting the following errors:
Notice: Undefined variable: logged in /home/hips/html/_layouts/header.php on line 119
Notice: Undefined variable: logged in /home/hips/html/_layouts/header.php on line 131
Notice: Undefined variable: logged in /home/hips/html/_layouts/header.php on line 138
How can this be? I'm defining the vars in the file before I include header.php! Shouldn't that work?
FYI, everything was working fine until I tried to use $logged
in the header.php file.