3
votes

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
You can not be sure, whether user will react to that prompt. What about opposite approach - autosave, like in google mail?Frantisek Kossuth
When do we autosave? each time user finishes doing some action? wouldn't that be an overhead to the server?Prabhakar

3 Answers

1
votes

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:

  1. A user requests a page from a server.

  2. 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.

  3. 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:

  1. A user requests a page from a server.

  2. 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.

  3. 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.

0
votes

In SSJS you can get the setting of the SessionTimeout with the following code:

facesContext.getApplication().getApplicationProperty("xsp.session.timeout", "30");

But this is a static value (in minutes). The session expires in X minutes (30 is default) after the last request of the current session.

0
votes

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.