Invalidate service now session in all nodes

sanjayg
Kilo Contributor

Hey Developers,

I have a requirement where a user wants an ability to kill another user's service now session .

Now, i did quite a bit of research and i learned that logged in users will only have the information of users who logged into the same node and doesnt communicate with the records of the other nodes (v_user_session).

Also there is an another table which says sys_user_session to get all the session records irrespective of nodes but i dont see a way to connect the dots and kill the session of the user.

Is there a way at all to achieve this ?

Thank you for all the help .

Sanjay

4 REPLIES 4

Gurpreet07
Mega Sage

Have you checked this thread.


Re: Invalidate/Timeout User Session


Yes gurpreet , I tried it and it doesnt work since that business rule also works specific to the nodes..


Gurpreet07
Mega Sage

What if you run this code from background script of in a Ui action.



  1. var sessions = GlideSessions.get().getLoggedInSessionList();  
  2. var it = sessions.iterator();  
  3. while(it.hasNext()) {  
  4.         var session = it.next();  
  5.         // If session is current users session, invalidate the session  
  6.         if (session.getUser() == user_id) {                       //user id of the user you want to invalidate the session
  7.                   var httpSession = session.getHS();  
  8.                   httpSession.setAttribute("locked_out", "true");  
  9.         }  
  10. }  

Nope , i was hoping that will work.. but Does not work ...


I donno somehow it's not picking up the information present in the other node.



You can try the following example.


login to your instance.(normal window)


Login to a different user in a private window



Now go to logged in users(normal window) , see if the user session of the private window shows up .


If not then try the script in the normal window ... you see that it will not invalidate the session of the private window.