Look at the following code: Is there something wrong with this picture when it includes header.php and echoes $_SESSION['hs_un']????
That block of code is really bad... what is this from? It depends on what the session is really. If its really sensitive info, I don't think you would want to display it like that.
if ($_SESSION['hsb_un'] != "") { include('includes/headerb.php'); } else if ($_SESSION['hs_un'] != "") { include('includes/headers.php'); } else { include('includes/header.php'); echo $_SESSION['hs_un']; } Code (markup): I don't know why you have an echo there. It only includes header.php when hs_un is an empty string.
You should use something like if (!isset($_SESSION['hsb_un'])) { include('includes/headerb.php'); } Code (markup): or if (empty($_SESSION['hsb_un'])) { include('includes/headerb.php'); } Code (markup): That is if you don't get any results. Also don't forget about session_start() before printing anything or calling a $_SESSION variable. I don't get it, when $_SESSION['hsb_un'] == "" && $_SESSION['hs_un'] == "" it doesn't include the header.php file or what? You are telling the script to print $_SESSION['hs_un'] only if $_SESSION['hs_un'] == "", ie when it is has an empty value. It will not echo anything, what would you expect?
The only reason i put 'echo' is for testing reasons. 'header.php' should be shown if there is no value for $_SESSION['hsb_un'] and $_SESSION['hs_un']. This is not sensitive information. I have reached this 'bad form', because using (!)empty() and (!)isset() did not seem to work, so i am thinking it is a session problem. I do have session_start(); could output buffering be the problem?
the problem is that $_SESSION['hs_un'] does echo and have a value, even thought the print statement is inside a conditional 'if' that requires there be no value for it. Thats the part that doesnt make sense to me!
Okay, now i have used isset(). I put !isset($_SESSION['hs_un']) on the 'if' that allows header.php. And then i put isset($_SESSION['hs_un']) on the conditional that allows headers.php. Both show!!!!!! what is going on!!!!?????? $_SESSION['hs_un'] returns true on both isset and !isset!!!!!!!!!!!!!!1
Ok guys nevermind; its fixed. The session_start() was in the headers, for which i was trying to determine the presence of a $_SESSION[''] value.
It is good practice to place session_start() on main pages, not on include pages. In your case you had to read a session variable, then load the header that contained session_start() and that's impossible. Maybe next time give some more details. Good luck with your project!