43
Views
3
Comments
Idle Session timeout alert.
Application Type
Reactive

Hello,
I am seeking a solution where if my application remains idle for 20 minutes, an alert warning should be displayed before logging out. I was able to achieve this using JavaScript, but it only worked when my application was open in a single tab.

In a scenario where the application is open in multiple tabs and I am actively working on one of them, alerts may appear on the other tabs. However, the session of our systems remains active, so the alert should not have appeared on those tabs.
Looking for solution for above scenario.

Additionally, is there any way to retrieve the maximum idle timeout value?"

Thanks In Advance

N_G

2019-01-07 16-04-16
Siya
 
MVP

To solve this, you could either use the BroadcastChannel API or, localStorage events alongside JavaScript's setTimeout and clearTimeout functions.

The BroadcastChannel API is great for allowing tabs to talk to each other. For a deeper dive into how it works, I suggest checking out the BroadcastChannel API documentation on MDN.

Alternatively you can use localStorage and its storage event, which is triggered when changes are made to localStorage from another tab. Please refer @ https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

2021-10-01 12-43-46
N_SG

Hi @Siya ,
Your explanation was very helpful. I was wondering if you could kindly provide a working example or any sample OML?
Thanks

2019-01-07 16-04-16
Siya
 
MVP

Please find the provided JavaScript reference attached. To test its functionality, copy the content and paste it into the JavaScript section of the "OnReady" event for a screen in your application. 

For quicker testing, consider adjusting the timeout value on line 13 to a shorter duration, such as 10 seconds (by setting it to 10000). Afterwards, open your application in multiple browser tabs. If there's no activity detected, a popup will appear across all tabs after the designated timeout period. Conversely, if there is activity, no popup will be triggered.

referncejs.txt
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.