- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 09:22 PM
I want to kill user session which are active since last 60 minutes.
Referring to below code snippet from various post and ServiceNow also sent this to me:
Solved! Go to Solution.
- Labels:
-
Architect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 09:41 PM
Hi @Priyanka Palask
You can use the 'name' field.
var exclusionList=['integration_user','svc_account'];
var gr=new GlideRecord('sys_user_session');
gr.addQuery("sys_created_on<javascript:gs.dateGenerate('"+sma+"')");
gr.addQuery('name','NOT IN', exclusionList);
gr.query();
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 09:40 PM
Hello @Priyanka Palask ,
To kill specific user session :
Go to "All-> User Administration -> Logged in users".
Here you will find all the logged in users and their transaction duration. Open the user record that you want to end and click "Lock out session".
This will end the session and the user will be re-directed to the login page. This will not lock the user, but only end the specific session.
If this solution helped resolve your issue, please consider marking it as helpful or correct.
This will assist others in finding the solution faster and close the thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 09:41 PM
Hi @Priyanka Palask
You can use the 'name' field.
var exclusionList=['integration_user','svc_account'];
var gr=new GlideRecord('sys_user_session');
gr.addQuery("sys_created_on<javascript:gs.dateGenerate('"+sma+"')");
gr.addQuery('name','NOT IN', exclusionList);
gr.query();
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2025 11:15 PM
Could you please help me understand why name is empty in user session table for so many records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 12:35 AM
@Priyanka Palask I'm not sure. It could be created for non-interactive sessions, but I might be wrong.