Session Scope

Session Timeout Notice Using Javascript

Sometimes in an Intranet you need to notify the client that his session is about to expire and let him to decide if he will renew his session or let it die. That can be done either on server or client side.

We will discuss here the client-side way using Javascript and/or Ajax to refresh the session.
The script offers two ways of refreshing the session, one by just reloading the page and other by calling an Ajax function.

If your template is a form, you will want definitively to use Ajax, or you would lose all the fields already filled in. If you are in a simple display page, refreshing that page will not cause any problems.

So, I used a sample my friend Pedro Claudio posted on the CF-Brasil mailing group, and modified it to be used in CF templates with CFAJAX components (not the CF8 tag). I also modified it to use the Javascript function “setInterval()” instead of the “settimeout()” which will continue counting the time after every renewal.

I created this test environment that you may download here.

Read More…