- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2021 04:57 AM
I am working on a requirement where I need to know if a user is currently logged into the system and has a valid session.
I know How to check for the currently logged in user. I want to know for a specific user.
- Lets say I have a X user and want to know he/she is currently logged into the system. How to achieve this?
- Also lets say I have a session ID. How to check if its still valid and not expired?
I have tried querying the "v_user_session_list" but it gives me only the current node users.
Any other way to know for overall users?
Help is much appreciated. Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2021 05:42 AM
Thanks guys, I was able to figure it out.
The table is sys_user_session table
Below URL will give you all the currently actively logged in User with a valid session ID
https://your_instance_name.service-now.com/sys_user_session_list.do?sysparm_query=nameISNOTEMPTY%5EinvalidatedISEMPTY%5Elast_accessedONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()%5Ename!%3Dguest%5EORname%3DNULL&sysparm_first_row=1&sysparm_view=
To cross verify the count use the below script.
var total_users = 0;
var diag = new Diagnostics();
while (diag.nextNode()) {
var diagNode = diag.getNode();
var ss = diagNode.stats.sessionsummary;
if (ss) {
gs.print(JSON.stringify(ss));
total_users += parseInt(diagNode.stats.sessionsummary["@logged_in"]);
}
}
gs.info(total_users);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2021 05:15 AM
Hi,
Are you saying this table "v_user_session" doesn't list all the users?
Anything specific you found that users from particular nodes are not captured in this table?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2021 05:20 AM
Hi Ankur,
Yes, The reason is there are 2 nodes for our instances. So It shows users on current node which I am logged in.
For more info please check this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2021 05:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2021 05:21 AM
Hi Sulabh,
This lists only those users who are logged into the current node.