How can you determine if an ASP (classic) session has expired in IIS 7.5 without having to refresh the session?

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.

Answer №1

When you call Session("username"), you are essentially refreshing the Session Object, which is why you won't see the popup.

An alternative approach would be to utilize the Global.ASA file to set up functions like Session_OnStart and Session_OnEnd to store information such as the SessionID and creation date/time in a database, allowing your script to check these records.

You can use both functions to insert and delete session information from the table.

For more information on Global.Asa Syntax (MSDN)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

GraphQL Shield throws an 'Unauthorized' error for a permitted mutation

I've been working on setting up a GraphQL API with apollo-server-express, and I'm trying to handle permissions using graphql-shield middleware. However, I'm running into some issues when it comes to allowing mutations to be executed. My aim ...

The issue with React Suspense not functioning properly has left me perplexed and I am struggling to identify the

I have been given a task to investigate why the code below is not functioning properly. This code is an attempt to utilize the React Suspense API, but it is not implemented correctly. There are 3 main issues with how these components are using Suspense ...

React: Issue encountered when updating props from parent component (Error executing removeChild operation)

Currently, I am utilizing react along with AJAX to retrieve data for a list. However, every time componentWillReceiveProps(nextProps) is triggered after the initial setup, an error occurs. This error typically arises when the URL for the AJAX call has chan ...

Modifying the nested data organization in Sequelize

I'm looking to adjust the data structure retrieved from an ORM query involving four tables. The product and category tables have a many-to-many relationship, with the product_category table serving as a bridge. Additionally, there's a fourth tabl ...

Understanding the lockfile: deciphering the significance of each line in the yarn.lock file

I'm curious about the meaning of each line in this file. I encountered issues with packages due to dependencies in my project. After upgrading nuxt from version 1x to 2x, all tests started failing. After spending hours searching online, I discovered ...

Sorting through a collection by using a nested array

I've been working on optimizing my code to prevent making new http requests to my API every time I need to filter results. Currently, I have an array called pageContent that is populated with data from an API fetch when the page loads. Each object in ...

Fetching specific information from MySQL using EJS

Check out the Github project here Currently, I am in the process of developing a Quiz creation application using EJS as the templating engine along with jQuery, Bootstrap, and MySql. I have encountered a challenge where I am trying to display the corresp ...

Node.js - Synchronize asynchronous calls to ensure coordinated execution in code

I am trying to figure out how to make a for loop with an async function wait until all the async functions called within it are finished before allowing the code to continue. In my scenario, I have a variable "bar" that contains a JSON array with other ne ...

Dealing with errors in JavaScript promises

I have a piece of Javascript code that involves asynchronous operations along with some synchronous post-processing, followed by more asynchronous operations (such as XHR requests, parsing the response, and making additional XHR requests based on the first ...

Using Angular2, summon numerous ajax requests and then patiently wait for the results

I'm facing an issue with my Angular code. Here are the functions I've been working on: private callUserInfo(): any { this.isLoading = true; return this._ajaxService.getService('/system/ping') .map( result => { this.user ...

Issue encountered when attempting to trigger an ionic modal from a custom control in Google Maps

I am facing an issue with my custom Google map control in Ionic framework. I want the control to open a modal when clicked, but I keep getting an error "Cannot read property '$$destroyed' of undefined" when I try to do so. On the other hand, anot ...

Tips on positioning a div based on the screen dimensions

In my table, there is an icon that reveals a chart as a popup when hovered over. This div is where the chart is displayed: <div id="chart-outer" style="@style" class="popup-chart close"> <h2 id="charttitle&q ...

Guidance on navigating to a different page using a specific identifier

I'm a beginner in Angular, currently working on developing a full stack MEAN application. I need some guidance regarding an issue I'm encountering. My goal is to create a form called 'fa-daform.component.html' that captures a brief desc ...

What is the most efficient way to establish a connection to "host:port" without relying on a web browser, utilizing only Node.js/JavaScript?

To establish a connection with a server (created using node js), we simply open the browser and include some code in a file like this: <script src="http://127.0.0.1:8080/socket.io/socket.io.js"></script> <script type="text/javascript">/* ...

Progressively modifying related elements over time intervals

I have a specific list of p elements in my HTML code that I need to modify sequentially with a time interval of 1 second. Here is the HTML: <p>Changing first sentence!</p> <p>Second sentence ready!</p> <p>Third one coming up ...

Click on the link within the Checkbox label on MUI

I am working on creating a checkbox for the "Terms of Use," using FormControlLabel to nest a Checkbox. However, I also need to include a link that opens a Dialog component displaying the terms. The challenge is that clicking on the link checks the checkbox ...

identifies a data point from a combined dropdown menu

Is there a way to detect a specific value from a multiplied combo box? For example, when the value in one of the combo boxes changes to "2", a component is displayed. However, if the value in another combo box changes to anything other than "2", the compon ...

Spin a vector using a perpendicular in Three.js

I need help with vector rotation in Three.js {x: 0, y: 0, z: 1} I also have a normal vector: {x: 1, y: 0, z: 0} How can I rotate the first vector based on the direction of the normal to achieve this result? {x: 1, y: 0, z: 0} Your assistance in this ...

Does a DOM API exist specifically for querying comment nodes within the document?

My document contains a debugging comment that appears as follows: <!--SERVER_TRACE {...}--> Is there a method to search the DOM and access this specific node? I would prefer a vanilla JavaScript solution, without relying on any external libraries. ...

Filter JSON data by month dropdown in AngularJS

Is it possible to filter JSON data using a dropdown with all 12 months listed, and then filter the results by month? I currently have a filter set up for filtering events by type, but I'm struggling to figure out how to filter the data by month using ...