you have this code on all your pages:
if($_SERVER["REQUEST_METHOD"] == "POST") {
$_SESSION['MM_Username'] = "".((isset($_POST["userName"]))?$_POST["userName"]:"") ."";
$_SESSION['MM_UserGroup'] = "";
}
this code will reset the MM_Username session variable any time there is a form post. the session will be set to the value of the userName form element. If the form does not include a userName form element, the MM_Username session will be set to blank.
that code should not be included on every page, only the page that the login form posts to. by including it on every page, you are bound to overwrite the session to b blank at some point.