xSession.new Method
Instantiates the xSession object, either for current session or for the session ID passed in as a parameter.
Syntax
public void new([int sessionId, boolean checkSession])
Run On
Called
Parameters
- sessionId
Type: int
The session ID for which information is requested; optional. If this parameter is not used, the object will be instantiated for the current session.
- checkSession
Type: boolean
A boolean flag that, if set to true, checks to determine whether the session specified by the _SessionId parameter exists.
The operation that checks whether a session exists might use a lot of system resources. This parameter is therefore set to false by default.
Examples
The following example returns a count of all the active sessions.
server static Integer getAllOnlineUserCount()
{
int counter;
int num = 0;
int maxSessions = Info::licensedUsersTotal();
xSession session;
UserInfo userInfo;
for(counter = 1; counter < maxSessions;counter++)
{
session = new xSession(counter, true);
if(session && session.userId())
{
select firstonly userInfo
where userInfo.Id == session.userId();
if (userInfo)
num++;
}
}
return num;
}