3

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

Prabhakar
  • 402
  • 6
  • 20

3 Answers3

1

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.

Jimmery
  • 9,783
  • 25
  • 83
  • 157
  • Thank you Jimmery, It makes sense..but to my knowledge we can never trust setTimeout to be accurate as it behaves differently on each machine, due to number of factors like CPU speed, machine config, etc.. – Prabhakar Jul 12 '15 at 07:36
  • 1
    True. But you are left in a position where setTimeout is inaccurate but it works, whereas what you are trying to do wont work over HTTP at all. Be aware that there are several methods for improving the accuracy of setTimeout, but even still this is just faking a 2 way connection over HTTP. For what you are trying to achieve (the server sending messages to the client), you should look into PUSH technology - https://en.wikipedia.org/wiki/Push_technology – Jimmery Jul 13 '15 at 09:53
0

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.

Sven Hasselbach
  • 10,455
  • 1
  • 18
  • 26
  • Ap per my knowledge above code gives session timeout defined in application properties, what I want is timeout which is defined in domino server document. I have a website with SSO and even if user is active there is some setting on domino server after which session for that user expires. – Prabhakar Sep 10 '13 at 12:42
0

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.