logged in user not showing in 'Logged in users' list?

georgechen
Kilo Guru

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)

find_real_file.png

but not shows in the Logged In Users list (v_user_session_list.do)

find_real_file.png

Any advice would be appreciated.

1 ACCEPTED SOLUTION

Rajesh Mushke
Mega Sage
Mega Sage

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

View solution in original post

7 REPLIES 7

Patrick DeCarl1
ServiceNow Employee
ServiceNow Employee

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.



System_Diagnostics___ITOM.png



To see what node your on, type in stats.do in the app menu.


Servlet_statistics___ITOM.png


Rajesh Mushke
Mega Sage
Mega Sage

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

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!


Rajesh Mushke
Mega Sage
Mega Sage

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