GetID()

var userId = User.GetID();

This method, defined on the User object, returns the user’s ID, which is its full username.

Warning

The current user object 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 or any of its methods/properties (see example below).

Example

{
  var user = Session.GetUser();
  if (user !== null) {
    var id = user.GetID();
    Log(id); // will log the user's ID, which is the full username
  }
}