Ending Sessions
- Last UpdatedNov 06, 2025
- 1 minute read
When the application is terminating, you can use the code in the Term script shown below to end the session. If you do not end a session, the MES service cleans it up as soon as it determines that the session is stale.
You can call the Term script to clean up and end a session. The Term script should be called one time by one Application Object.
You can use the Term script as either an OffScan or Execute script with some attribute-based trigger. If you use it as an Execute script, you should mark it as an asynchronous script.
' Term Script
dim clientSession As aaFactMES.aaClientSession;
dim result As aaFactMES.Result;
' Get the singleton client session
result = aaFactMES.aaClientSession.GetInstance();
clientSession = result.Value;
if ( clientSession <> null and clientSession.SessionId <> -1 ) then
' log everyone off and stop session
clientSession.LogOffAllUsers();
clientSession.EndSession();
LogMessage("Session Ended");
endif;