GlideSessions.get().getLoggedInSessionList(); -- Node Specific?

andrew_lawlor
Giga Expert

var loggedIn = [];

  var sessions = GlideSessions.get().getLoggedInSessionList();

  var it = sessions.iterator();

  while (it.hasNext())

  {

  var session = it.next();

  var id = session.getUser();

  var user = new GlideRecord('sys_user');

  user.get('user_name', id);

  loggedIn.push(user.sys_id);

  }

Above is an excerpt of a script that I wanted to use to get the sys_ids of all currently logged in users. It works perfectly fine, however it only picks up users logged into the current node. Is there a way to get a session reference for all users across all nodes on a given instance?

Thanks in advance!

1 ACCEPTED SOLUTION

nikita_mironov
Kilo Guru

The first idea that came to my mind is to run this code as a part of script executed by sys_trigger records attached to each of your UI nodes and populate a custom table with some schedule. Next you will be able to query that table data from anu none. The only negative effect is that your list is not real-time but a historical snapshot (we have a schedule-based population). Other than that I do not see any other method of exchanging informtion about logged in users between your UI nodes.


View solution in original post

1 REPLY 1

nikita_mironov
Kilo Guru

The first idea that came to my mind is to run this code as a part of script executed by sys_trigger records attached to each of your UI nodes and populate a custom table with some schedule. Next you will be able to query that table data from anu none. The only negative effect is that your list is not real-time but a historical snapshot (we have a schedule-based population). Other than that I do not see any other method of exchanging informtion about logged in users between your UI nodes.