In Login Page, add this:
$_SESSION['uid'] = $row[1];
Suppose row[1] includes the user id or username
Then in the sidebar:
<?php echo $_SESSION['uid']; ?>
I dont know what the rank is for but you can echo out the rank in a similar way as username
4
solved Retrieving username from MYSQL database [closed]