Skip to content

GetUserID()

ts
GetUserID(): string;

Returns the ID of the currently logged-in user for this session. If no user has logged in yet, this function returns an empty string.

NOTE

Unlike Session.GetUser(), this function never returns null. If no user is authenticated, it simply returns an empty string, making it safe to use without additional null checks.

Example

ts
{
  var userid = "unknown";
  if (Session) {
    userid = Session.GetUserID();
    if (userid === "") {
      userid = "unknown";
    }
  } else {
    Log('Session object is not available.');
  }
  NotifyViaTelegramBot("User [" + userid + "] just logged in.");
}