Trigger client side event when session in lost

asp-classic, javascript, session

Solution

One way to do it is to set client-side timer set to the same time as session expiration time.

Let's say your session is set to expire after 20 minutes. When page loads - client-side timer set to 20 minutes kicks in. If user does any server interaction (submits form etc.) - timer is reset. But if nothing happens during this 20 minutes - timer counts down and you get your event.

Problem

As some of you probably know, Facebook is using this kind of "system" where a popup is displayed when a user session is lost due to inactivity or distant session close. I already saw and read this Node.js question but didn't find anything. I am working for a Canadian computer business our main product is a CRM and everything is coded using Classic ASP. I know. The whole web-based application is working great and since we host the site on our servers, it is possible if necessary to open ports and use sockets. Here goes the main question: is there a way (using a javascript library or a jQuery plug-in maybe?) to trigger a client-side event when the session expires or is simply lost due to a server reset for example? Of course, the best would be to use another solution than sending an AJAX request every second to validate if the user session still exists. If it can help, there is a maximum of about 3'500 users connected at the same time and our servers can easily handle more traffic. The servers are working on Windows Server 2008 along with IIS 7. Unfortunately, I cannot provide any code blocks or screenshots for this question since there is nothing to debug. One idea would be to use an AJAX request to a file that does not return anything and hangs there. If session is lost (inactivity or server reset), the AJAX request will trigger an error and the "error" function will be triggered. Would that be something to consider? Or else, any other suggestions?

Original source