- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2018 06:14 PM
Hi Community gurus,
Investigating ways to expired session user, I was wondering any reasons that a user who's logged in but not showing in 'Logged in users' list?
The user can be seen in User Tokens list (sys_user_token_list.do)
but not shows in the Logged In Users list (v_user_session_list.do)
Any advice would be appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2018 06:48 PM
Hey Chen,
The table dynamically gets populated with users sessions. ServiceNow stores all of its configurations in database, but logged in sessions is actually part of the application layer and not the storage layer. As such, it's reading the logged in sessions from the Java application. As the applications run on each individual mode, and the nodes themselves do not communicate with one another, all the logged in users table shows you is the logged in users on the application node that you're on. Logging in to another node is a complete random hit and miss exercise of clearing your cookies and reconnecting to ServiceNow, hoping the load balancer sends you in a different direction to the node you want to be on. Not great then for finding out whose on your system.
Please Refer:
https://servicenowgems.com/2016/04/28/finding-logged-in-users/
how to get the number of users logged in?
Let me know if it doesn't works.
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2018 06:48 PM
George,
If your instance has more than one app node, you will only see the users logged in under the same node you are logged in and looking at.
To see how many nodes you have, look at homepage "System Diagnostics.
To see what node your on, type in stats.do in the app menu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2018 06:48 PM
Hey Chen,
The table dynamically gets populated with users sessions. ServiceNow stores all of its configurations in database, but logged in sessions is actually part of the application layer and not the storage layer. As such, it's reading the logged in sessions from the Java application. As the applications run on each individual mode, and the nodes themselves do not communicate with one another, all the logged in users table shows you is the logged in users on the application node that you're on. Logging in to another node is a complete random hit and miss exercise of clearing your cookies and reconnecting to ServiceNow, hoping the load balancer sends you in a different direction to the node you want to be on. Not great then for finding out whose on your system.
Please Refer:
https://servicenowgems.com/2016/04/28/finding-logged-in-users/
how to get the number of users logged in?
Let me know if it doesn't works.
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2018 02:01 PM
Thanks Rajesh, I am still testing the time out in my development instance; It's become more complex than I thought. So now I have a schedule job running every 10 minutes,
//20180212 GC Remove expired user tokens and also log out the users
gr = new GlideRecord('sys_user_token');
gr.orderBy('expires');
gr.query();
while (gr.next()) {
var now = new GlideDateTime();
var gdtExpire = new GlideDateTime(gr.expires);
if (gdtExpire.compareTo(now)<0) {
var expiry = gdtExpire.getDisplayValue();
var user = gr.name;
gs.log('debug: Deleting user token:' + gr.name + ',' + gdtExpire.getDisplayValue());
gr.deleteRecord();
gs.log('debug: Token deleted, user: ' + user + ',expiry:' + expiry);
var sessions = GlideSessions.get().getLoggedInSessionList();
var it = sessions.iterator();
while(it.hasNext()) {
var session = it.next();
// If session is current users session, invalidate the session
//gs.log(session.getUser());
if (session.getUser() == gr.name) {
gs.log('debug: logging out user, session.getUser()=' + session.getUser());
var httpSession = session.getHS();
httpSession.setAttribute("locked_out", "true");
}
}
}
}
Thanks for being helpful Rejesh!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2018 03:50 AM
Hey georgechen,
Any update?
Let me know if you need more help.
If your query is answered, please close this thread then only this will be helpful for other community users.
if i have answered to your query, Please Mark my response as Correct/Endorse if applicable.
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke