Richard Pearce
Rank: #5470
How to obtain the browser session timeout value ?
895Views
11Comments
Question
Hi !
In my web application I want to obtain the browser timeout info: either the timestamp the session will end, or the timestamp the session started plus the session timeout in minutes will do fine.
How can I do this ?
Cheers, Richard
10 Sep 2019 Copy post link
Jorge Martins MVP Rank: #21 Hi Richard, The timestamp the session started plus the session timeout is useless... the timeout countdown is reset every time the user interacts with the server. If you want to determine when the countdown for timeout starts, you can can go to the Logic tab, right-click on the Server Actions folder, select Add System Event and then On Begin Web Request. This will create an action that will run every time your module handles a new request. Here you can store in Session variable, or in an Entity the last time it was "touched". If you know the timeout (this is a server configuration), you can determine the timestamp the session will expire. You would need to add this to every module you want to collaborate to determine this info though. Another option is adding to the default Layout of your screens a Web Block that doesn't have any UI but on its preparation does the same kind of logic. Screens that are built afterwards will include this by default, older screens you will have to manually add the Web Block to them. 10 Sep 2019 Copy comment link 1 reply 12 Sep 2019 Show thread Hide thread Richard Pearce Rank: #5470 Jorge Martins wrote: Hi Richard, The timestamp the session started plus the session timeout is useless... the timeout countdown is reset every time the user interacts with the server. If you want to determine when the countdown for timeout starts, you can can go to the Logic tab, right-click on the Server Actions folder, select Add System Event and then On Begin Web Request. This will create an action that will run every time your module handles a new request. Here you can store in Session variable, or in an Entity the last time it was "touched". If you know the timeout (this is a server configuration), you can determine the timestamp the session will expire. You would need to add this to every module you want to collaborate to determine this info though. Another option is adding to the default Layout of your screens a Web Block that doesn't have any UI but on its preparation does the same kind of logic. Screens that are built afterwards will include this by default, older screens you will have to manually add the Web Block to them. Hi Jorge, Thanks for the suggestions. For a warning before a timeout on a critical workflow the first suggestion might work, but for a message after timeout both incur a large overhead and are probably overkill. For the latter I think I might raise an idea with Outsystems for them to create a new Timeout Exception. Cheers, Richard. 12 Sep 2019 Copy comment link Daniël Kuhlmann MVP Rank: #5 Richard, What is it that you try to do with that the session timeout information? Regards, Daniel 10 Sep 2019 Copy comment link 1 reply 12 Sep 2019 Show thread Hide thread Richard Pearce Rank: #5470 Daniël Kuhlmann wrote: Richard, What is it that you try to do with that the session timeout information? Regards, Daniel Hi Daniel, Firstly I would like to send the user a message when they have timed out. Optionally for some critical workflows I would like to give them a 2 minute warning. Cheers, Richard 12 Sep 2019 Copy comment link Eduardo Jauch MVP Rank: #7 Hi Richard, A Timeout exception would be thrown only when the user tried to reach the server, after the timeout happened. This is because the server just do not keep any information about users or requests in memory. After a response is sent back to the client, the server just forgets everything about the request made. The client simply doesn't exists anymore for the server. It would never know when the session would timeout. Actually, if the user makes a request to an anonymous page after the timeout, the session is reset, but other than that the user may not even notice. If the request is for a non anonymous page, a security exception will be thrown. A timeout exception, on this context, could be still interessant, but... Cheers. 12 Sep 2019 Copy comment link J. MVP Rank: #14 It's possible, You have to know upfront what the IIS session timeout is. by default 20min, but it can be different :) In any case, create a webblock. This will be included in your layout_webblocks, so that every screen is using it. In the prep you (re)set a cookie -> this way the you keep having the samish sliding timeout.. With a simple js-heartbeat mechanism, you check the time with the cookie and call a fakenotify for example if the timeout is within 2 minutes, then the fakenotify is called and you do a popup or something like that. that logic is of course in that same webblock. TL;DR; keep a cookie updated by actions on the server and use js-heartbeat to check the cookie and act accordingly 12 Sep 2019 Copy comment link Eduardo Jauch MVP Rank: #7 J, the pop-up would have to be done in Javascript, no? The fakenotify would reach the server and reset the counter... 12 Sep 2019 Copy comment link 1 reply 12 Sep 2019 Show thread Hide thread J. MVP Rank: #14 Eduardo Jauch wrote: J, the pop-up would have to be done in Javascript, no? The fakenotify would reach the server and reset the counter... No. It's a ajax-request, so the prep will not get hit. (and to be sure you might want to add some more info etc. etc.) but it really does not matter, because at that point in time you are going to show the popup. preferably locking the screen of course ;) 12 Sep 2019 Copy comment link
Log in to Answer