The "Session" object

Almost every script run by Syncplify Server!’s event-handling subsystem exposes a pointer to a built-in object called Session. This object represents the current client session that the server is serving, and to which all script methods will apply.

The Session object is a standardized interface, common to all protocol handlers (so you can count on its consistency), and is defined as follows:

class Session {
  function GetID(): string;   
  function GetUser(): User;
  function GetCurrentVFS(): VFS;
  function GetVirtualSite(): string;
  function GetRemoteAddress(): string;
  function GetClientVersion(): string;
  function GetProtocol(): string;
  function GetStartTime(): Date;
  function GetLastActivity(): Date;
  function BlockOperation(): void;
  function AddCustomData(s: string);
  function GetCustomData(idx: number): string;
  function GetAllCustomData(): string[];
  function AddQuestion(pos: number, q, a: string, echo: boolean): void;
  function AddQuestionPassword(pos: number, q: string): void;
  function AddQuestionTOTP(pos: number, q: string): void;
  function AuthenticateUserFromScript(): void;
  function GetAbsPath(): string;
  function GetAbsTargetPath(): string;
  function GetRelPath(): string;
  function GetRelTargetPath(): string;
  function RemoveFromListDir(value: string);
  function GetLastCommand(): string;
  function GetLastCommandTime(): Date;
  function GetLastError(): string;
  function GetLastErrorTime(): Date;
}

Use the navigation menu here on the left to access specific documentation for each member function of the Session object.

Warning

The Session object is always null (and, therefore, it cannot be used) in scripts run by event-handlers that fire before the actual client session can be created, specifically: OnNewConnection and BeforeSendSoftwareID.

Example

Here’s a short example that logs session ID and username of the logged in user; typically the OnAuthSuccess is the appropriate event-handler to trigger the execution of this script.

{
  var sid = Session.GetID();
  var uname = Session.GetUser().ID;
  Log('User ' + uname + ' connected with session ID ' + sid);
}