Saturday, June 13, 2009

Current session id

You can retrieve the current client session id by using the following function: SessionId().

So, for example in a job, to show the current session id

static void ClientSessionJob(Args _args)
{ ;
info(strfmt('This client session id is %1',int2str(SessionId())));
}

You can use this function together with the class xSession to collect more info.
The class xSession is responsible for retrieving various session information. Like the logon date and time:

static void LogonDateTime(Args _args)
{ xSession xSession;
;
xSession = new xSession(SessionId());
info(strfmt('The logon date and time were %1',DateTimeUtil::toStr(xSession.loginDateTime())));
}

Or the current AOS server name you're logged onto:

static void CurAOSServerName(Args _args)
{ xSession xSession;
;
xSession = new xSession();
info(strfmt('Current AOS server name logged onto is %1',xSession.AOSName()));
}

Instantiate the class xSession without a session id to get info for the current session.

The user id used to create the session is also available. But there is an alternative for this one:

static void ClientUserId(Args _args)
{ ;
info(strfmt('Current logged on user id %1',curUserId()));
}


Try out for yourself!

No comments:

Post a Comment