I use ajax to get logged in user info when needed via javascript.
http://yoursite.com/[forum root]/ajax/api/user/fetchCurrentUserinfo
This will yield a plethora of useful and useless information in a JSON object that you can use in your custom page. The following example will report back the username of the logged in user or alert to login.
Example, edit the url in the code.:
Code:
<html>
<body>
<h1 class="username"></h1>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$.ajax({
url: 'http://yoursite.com/[forum root]/ajax/api/user/fetchCurrentUserinfo',
type: "POST",
dataType: 'json',
success: function(response) {
if (response && !response['errors'] && response['userid'] !=0) {
$( ".username" ).append( response['username'] );
}
else {
alert('You must login!');
}
}
});
</script>
</body>
</html>