Client script to return user session time left

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2016 08:20 AM
Is there any javascript that I can put into a Client Script to get the logged in user's session time?
I'm currently doing this in some UI Pages:
var _oneHourTimer = 0;
var tickerSeconds = 3600;
startOneHourTimer();
function oneHourTimerTicker()
{
var el = document.getElementById('sessionReminder');
if (el)
el.innerHTML = ("Your session will expire in " + (--tickerSeconds) + " seconds.");
if (tickerSeconds == 600) // 10 minute warning
alert("Your ServiceNow session will expire in 10 minutes. Be sure to SUBMIT any unsaved form data.");
if (tickerSeconds == 300) // 5 minute warning
alert("Your ServiceNow session will expire in 5 minutes. Be sure to SUBMIT any unsaved form data.");
if (tickerSeconds == 60) // 1 minute warning
alert("Your ServiceNow session will expire in 1 minute. Be sure to SUBMIT any unsaved form data.");
}
function startOneHourTimer()
{
var el = document.getElementById('sessionReminder');
if (el)
el.innerHTML = ("Your session will expire in 1 hour (" + tickerSeconds + " seconds)");
_oneHourTimer = setInterval(function(){ oneHourTimerTicker(); }, 1000);
}
This works fine, but instead of a hard-set guestimation of 3600, I'd like to pull the actual session time left before ServiceNow logs them out.
Any way to pull that data?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2019 07:27 PM
I would recommend using a new thread for this as then it's yours, you can attribute the correct answer and it will appear as not responded to.