Logging into Sessions
- Last UpdatedNov 06, 2025
- 1 minute read
Once a session is located or started, then it is possible to login a user. It is still possible to make API calls without a logged on user as the system will determine the user to supply to the edited_by fields of the database. If you want to update the database, the recommended practice is to login to the session with a valid MES user. If you do not login with a user, it may result in the Middleware user from the database connection being logged.
For an example, see the sample script
Dim Result as aaMES.Result;
dim userID as string;
userID = me.MES.userId;
dim userPw as string;
userPw = me.MES.Password;
' reset command
me.cmdLogon = false;
me.cmdLogoff = false;
' do we have a client session?
If me.SessionID > 0 then
' logon the user
'aaMES.Core.aaSession.LogIn( sessionId, userId, userPw );
result = aaMES.Core.aaSession.LogIn( me.sessionId, userID, userPw );
if result.Success then
me.resultText = "MES Logon Succeeded for user " + me.MES.userID;
else
me.resultText = "User Logon Failed: " + result.Exception.Message;
endif;
else
me.resultText = "No MES session started for Logon User";
endif;