GetUser()

// in class: Session
function GetUser() User;

This function returns a pointer to an object that represents the authenticated User, if any, for the current session.

Warning

The returned pointer may be null when the client session has started but no user has been authenticated yet, so this condition must be checked before using the returned object.

Example

{
  var user = Session.GetUser();
  if (user !== null) {
    // we have a valid User object, so we can use it here...
  }
}

Certain event-handlers can only be triggered by conditions that can never happen without an authenticated user. Think about AfterFileUpload for example: it runs a script after a file has been uploaded, and no upload can ever occur unless a user has already authenticated. So, when the script is run by one of these event-handlers, the developer may skip the null-check.