What you did looks good, just some changes:
<?php
if(!isset($_SESSION['steamid'])) {
steamlogin();
} else {
header('Location: loggedUserPage.php');
//It's better to redirect the user to a different page on this scenarios
} ?>