Skip to main content
June 12, 2009
Question

Session Expiration Alert

  • June 12, 2009
  • 1 reply
  • 519 views

Hello,

Does anyone know how to write a session expiration alert module whereby a user gets notified if their login session is about to expire with the possibility for the user to extend their session should they choose?

Regards,

Alex

    This topic has been closed for replies.

    1 reply

    ilssac
    Inspiring
    June 12, 2009

    You don't.

    At least not with a normal HTTP web applicaiton.  There is no effective way to PUSH messages to a client do to the stateless nature of the HTTP standard.  You can only respond when and if the browser makes a new request in the future.

    A common solution is to use a bit of client side code in JavaScript to create a countdown timer of a similar duration as the session time out on the server.  Then have the JavaScrip dispaly a message when the session is about to expire.

    With AJAX it would be easy to have the JavaScript then respond to an action by the user to submit a new HTTP request behind the scenes that will extend the session period on the server.  Just know that for the server to know what session you want to work with you need to pass the session identifiers.  Usually CFID and CFTOKEN but can be a JSESSIONID cookie.  Normal browser request will automatically include these cookies with no effort.  AJAX xmlhttprequest objects do not automatically do this and you will be reqired to incorperate that functionality.

    Finaly you can use something beyond basic HTTP that does maintain a connection with the server that does allow messages to be pushed from the server to the client.  The Adobe product for this is Flex that build Flash user interfaces that can use available functionaility to create a permanent connection with a server, ColdFusion servers are particularly easy to use.