There is no need to pass the userName around as much as you do.
this should be sufficient:
session_start();
$_SESSION['userName'] = $_POST['userName'];
note how there is an under score key in $_SESSION, it is important that you always validate user input.
Then on your other pages you would have to do:
session_start();
echo $_SESSION['userName']
//.....