Session logout/restart through server side script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2012 08:53 AM
Hi,
Is there any way by which we can logout or restart user session in a server-side script ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2012 01:57 PM
I have never had a business case to do this, but I think you can do it to a current user session by using the setLoggedIn() function.
Here is an example:
//log out of current session
gs.getSession().setLoggedIn(false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2014 08:55 AM
Did you find a solution that worked?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 08:02 PM
The example John provided does not work on Geneva or Helsinki. But I found a solution!
gs.getSession().loggedIn = false;
Edit: The above solution worked too well. I had to restart my browser to be able to log back in. I found a different solution:
var gr = new GlideRecord('v_user_session');
gr.get('session_id',gs.getSession().sessionID);
gr.locked = true;
gr.update();
Warning: I got the follow error message: getEventTarget() called with invalid record reference: v_user_session.b3a6663f6f37d200234f5bc44b3ee414 for event: user.view, could have been deleted