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?  
kggan99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.