I am currently working on an ASP classic application that is running on IIS 7.5. My goal is to display a popup overlay on the user's window if their session has timed out without any interaction with the machine. For example, if the user walks away and forgets about it, I want the popup to be waiting when they return.
To achieve this, I have set up a background function using jQuery's setInterval method to send an ajax request to a page on my server called ajax-check-session.asp. This page simply checks if the session still exists and writes a '1' or '0' accordingly.
The session checking functionality works well as I can log out from a different tab and see the pop-up in other tabs using the same session. However, after leaving a tab idle for 20 minutes (the Session.Timeout value), the pop-up does not appear. I suspect this is because the ajax request to ajax-check-session.asp refreshes the session every 3 seconds, preventing it from timing out.
Below is the code snippet for ajax-check-session.asp:
<%Option Explicit
Response.Write LoggedIn()
Function LoggedIn
Dim strUsername
strUsername = Session("username")
If strUsername = "" Or isNull(strUsername) Then
LoggedIn = 0
Else
LoggedIn = 1
End If
End Function
%>
I would like to know if accessing the page every 3 seconds is causing the session to not time out. If so, I am looking for alternative techniques or suggestions to modify the code/server to prevent the session from refreshing. I have tried setting EnableSessionState=False on this page, but then I lose access to the Session variable entirely, making it difficult to check if the session has expired.