How can I refresh a user session via script

Joey Wan Kenobi
Tera Guru

Generally, after a user gets a new role, it seems like the session needs to restart before the system recognizes it the new permissions.

I'd like to know if I can force a user's session to refresh VIA script after they were awarded a role in the same script, so that they immediately experience the permissions granted by the role.

In other words, I have a script that essentially changes a user's role. At this point in the script, I would like to restart the user's session so that their session immediately loads with the new role.

If possible, i would like to avoid locking out their session as that causes the user to go to the log out page.

We are running Helsinki, patch 9.  

2 REPLIES 2

Deepak Ingale1
Mega Sage

Hi,

An undocumented way to do it is using below code.

var sm = GlideSecurityManager.get();
sm.setUser(gs.getUser());

Priyanshu
Giga Expert

Hello all,

I have the session id and user id of the user. I want to create a scripted API which will take input as session id and user and it will check it in logged in user table if the session id or user exist in return it should give me the complete details of the user from user table.

I am struggling with the script, Request you all to help me out on this it is a critical requirement.

Thanks in advance