What is the minimum necessary code to keep a session alive in classic ASP?
Asked Answered
C

3

5

I have a classic ASP site that I would like the sessions to stay alive as long as the user has a page open. So I used some Javascript to periodically call a 'keepalive' ASP page to keep the session alive so the timeout is not reached.

What do I need to put in the ASP page code to make sure it renews the session timer? Can it be a blank page or do I need to hit the Session object?

Commute answered 20/9, 2011 at 3:40 Comment(0)
S
6

From MSDN:

A session automatically ends if a user has not requested or refreshed a page in an application for a specified period of time.

Based on that description, I don't think it matters what's in your "keepalive" script, as long as the request is made.

Sandstrom answered 20/9, 2011 at 4:34 Comment(1)
All sessions will be killed when the Application Pool recycles, so check the settings in IIS as the defaults are set to recycle after a certain number of requests or a period of time. You can configure it to recycle at specific times of day (say during your quietest period) so that fewer users are affected.Elysia
P
1

I use a small inline frame at the bottom of a page to do this in admin sessions where the user is editing conent. All that's in the frame page is a meta refresh that fires every 5 minutes to keep the session alive. Works great.

Possess answered 20/9, 2011 at 15:23 Comment(2)
This solution didn't work in case user may close their browserPositronium
That's how sessions work. They are meant to be temporary, and won't persist if the browser is not active.Possess
S
0

It has been my experience that as long as you perform some kind of server process periodically, the session doesn't end.

What I do is have a javascript function that is periodically run via a setInterval() function call in the onLoad process of the tag.

In that function I execute a server-side SQL query.

I place this inside the section with all of javascript and styleshooe loads:

Then I place the following lines right after my tag:

--> RSEnableRemoteScripting("."); -->
Sweptback answered 9/2, 2022 at 18:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.