Warn a user before a session timeout

Brian Bush
Giga Guru

We have set glide.ui.session_timeout to 15 minutes as per our own corporate policy.

We have also set glide.ui.forgetme as per ServiceNow hardened instance recommendations.

Has anyone come up with a good way to warn users before their session times out?

It seems like some combination of v_user_session and gs.getSession might be useful.

1 ACCEPTED SOLUTION

I've been working on a Platform session timer, you can view my code on my github.   I'm still working on the documentation and we are testing in our corporate development environment.   https://github.com/xxJimxx/SNTimeout/  



Let me know what you think or if you have improvement suggestions.


View solution in original post

11 REPLIES 11

Harsh Vardhan
Giga Patron

Hi Brian,



Please check the thread below. Hope it will help you.



Client script to return user session time left



Thanks,


Harshvardhan


Deepa Srivastav
Kilo Sage

Check below:


Session Timeout timer



Please mark Helpful, Like, or Correct Answer if applicable.


Brian Bush
Giga Guru

I've been looking into this for a little while now and don't think it's quite what I want.


It seems like I should be able to put a business rule on v_user_session that starts a client timer for the user and resets it on update. Then I could use a UI Notification to warn the user.



Has anyone attempted this approach?


Kalaiarasan P posted some client side code to countdown and alert:



function idleLogout() {


      alert('Starting to kick you out');


      var timer;


      window.onload = resetTimer;


      window.onmousemove = resetTimer;


      window.onmousedown = resetTimer;


      window.onclick = resetTimer;


      window.onscroll = resetTimer;


      window.onkeypress = resetTimer;



      function logout() {


              alert('You are being kicked out');


      }



      function resetTimer() {


              clearTimeout(timer);


              timer = setTimeout(logout, 3000);   // time is in milliseconds


      }


}


idleLogout();



I actually really like this in theory, but the problem is that it does not call resetTimer at the right times. For a Session timeout, the timer should only be reset when there is a call back to the Server, because the Server is what actually manages the session.



This is the difficultly. I need to figure out a way to run a timer on the server side that is reset on a server side call and then popup a client side alert on timeout.



I don't feel like I've seen a complete solution, yet.