[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 548
  • Last Modified:

How To Maintain Session Variable Value ?

Hi Expert:

I use many Session Variable in my pages.But the problem is that the value stored in the session variable will be gone if the user doesn't browse the pages for some times. So is there any way that can extend life span of the session variable as long as the user doesn't close the browser? Is there something to do with the session_onstart and session_onend in global.asa file?  
0
kggan99
Asked:
kggan99
  • 3
  • 2
  • 2
  • +4
1 Solution
 
mmipsCommented:
The following excerpt can be found at MSDN search for "ASP and Web Session Management" it is a backgrounder article...

Managing ASP Sessions
The server will maintain a user's session data for the lifetime of the session. A script can end a session programmatically by calling the Abandon method of the Session object. When a user completes an application and a session is no longer needed, the script can simply call Session.Abandon to end the session and free the server resources used by that session. A session can also end if the user does not make any HTTP requests to the ASP application for a specified time-out period. This period defaults to 20 minutes, but can be adjusted by setting the Timeout property of the Session object. If a user begins a session, but stops making requests to the Web application, ASP will time out the session after the specified idle period expires. The Session object also exposes a SessionID property. SessionID is a LONG datatype that uniquely identifies the user session.

0
 
JOKCommented:
So, if you go into the Internet Service Manager (MMC), you can increase the timeout.

Also, you could go to a cookie based method. A cookie will persist until the "expiry date", which you can set.
0
 
mmipsCommented:
Or just use the Session.Timeout [ = nMinutes ]....Then it is controllable on a page by page or session by session basis
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
TTomCommented:
Be aware that, unless you use it carefully, extending the session timeout property maintains ALL server variables for ALL sessions.  I am not sure you can adjust it on a user by user basis (for simultaneous sessions), but I could be wrong.  For a popular site, this could become a drain on server resources.

Tom
0
 
mmipsCommented:
TTom is correct about resource drain...We made a change from 20 to 60 minutes and killed a server with half a gig of memory.

The way they describe Session objects I believe they are stored on a user basis which means timeouts can be controlled on a session by session basis...see

ASP and Web Session Management
Michael P. Levy
Senior Consultant, Microsoft Consulting Services

April 2, 1997

on the webworkshop on MSDN
0
 
rupertsCommented:
Alternative is to use cookies if you have a resource problem!
0
 
kbalarajuCommented:
Cookies works fine!!! But the user can disable them. So we may not completely depend on the cookeis.
0
 
JOKCommented:
You can detect if the user has disabled cookies and deny access/redirect them to some other page.
0
 
xyzffffCommented:
you can use:
time=240    'two hours
session("yoursession")="xyz"
Session("yoursession").ConnectionTimeout=time
when you
0
 
xyzffffCommented:
you can use:
time=240    'two hours
session("yoursession")="xyz"
Session("yoursession").ConnectionTimeout=time
or you can modify IIS setting
0
 
RayFryeCommented:
I have tried the accepted answer and get a message indicating:

Microsoft VBScript runtime error '800a01a8'

Object required: 'Session(...)'

/default_test.asp, line 14

Line 14 is:
Session("yoursession").ConnectionTimeout=time

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now