How to get session timeout of Domino server in XPages-SSJS. I want to prompt user to save his/her data before session expires. Thanks
3 Answers
Servers only communicate with users when those users make a request to the server.
Because of this, servers cannot send information to the user if they haven't requested it.
For example:
A user requests a page from a server.
The server sends that page back to the user, and creates a session for that user. The session is set to expire in 5 minutes.
Those 5 minutes are up, and in the meantime the user hasn't requested any further pages. So the users session ends, but because the user isn't making any requests, the server has no way of communicating this to the user.
This is just the way that HTTP traffic is designed to work. There are ways around this however, and by altering the example above I will show you one of the easiest ways:
A user requests a page from a server.
The server sends that page back to the user, and creates a session for that user. The session is set to expire in 5 minutes. The page that the server sends back has a javascript
setTimeout
function which is set to fire off just before the session of the server expires.Those 5 minutes are up, and again, the user hasn't requested any further pages. So the users session ends and the server has no way of communicating this to the user. However, javascript on the page knows that the session on the server is due to expire, and fires off an alert to tell the user to save their work.
Well the timeout is reset with every interaction between server and client. So what could be done is basically have a count down on the client side that resets after every new request. And that could also be used client side to trigger a save interaction for a defined time prior to the actual session timeout.
Whether this makes sense or not is debatable... Alternatively auto-saving could be implemented aswell.