Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does the session variable not persist after a long time

Status
Not open for further replies.

williadn48

Programmer
Oct 27, 2006
29
US
This code works fine after a few minutes. If I leave the web page up and running for a long time (there is a hidden timer in the background), some of the variables go missing causing an Out of Present Range error. The holdstarttime session variable gets populated with now() when I click a start button earlier in the session. Yes, there is a date and time in that session variable initially. But if I wait an hour or so, and come back to the session and click stop, the holdstarttime session variable is empty.

if Request.form("hdnAction") = "Stop" then

dim theTimeatStop
theTimeatStop = now()

dim theTimeToComplete
dim hStartTime

hStartTime = Session("holdstarttime")

theTimeToComplete = DateDiff("s",hStartTime,theTimeatStop)

set cmdUPDATE = Server.CreateObject("ADODB.command")
cmdUPDATE.ActiveConnection = strCONN_DATA

cmdUPDATE.CommandText = "[sp_New_Update_tblECMTimeTrackingMain]"
cmdUPDATE.CommandType = 4

set param = cmdUPDATE.CreateParameter("@Associate",129,1,6)
cmdUPDATE.Parameters.Append param

set param = cmdUPDATE.CreateParameter("@EndTime",135,1,8)
cmdUPDATE.Parameters.Append param

set param = cmdUPDATE.CreateParameter("@TransxStatus",129,1,50)
cmdUPDATE.Parameters.Append param

set param = cmdUPDATE.CreateParameter("@QCBatches",129,1,4)
cmdUPDATE.Parameters.Append param

set param = cmdUPDATE.CreateParameter("@Comments",129,1,5000)
cmdUPDATE.Parameters.Append param

set param = cmdUPDATE.CreateParameter("@SecondsElapsed",3,1,4)
cmdUPDATE.Parameters.Append param

'cmdUPDATE.Parameters(0) = strRowID
cmdUPDATE.Parameters(0) = trim(Request.Cookies("cUSERID"))
cmdUPDATE.Parameters(1) = theTimeatStop
cmdUPDATE.Parameters(2) = "Function Completed"
cmdUPDATE.Parameters(3) = meBatches
cmdUPDATE.Parameters(4) = meComments
cmdUPDATE.Parameters(5) = theTimetoComplete
cmdUPDATE.Execute lngRECS,,128

meFUNCAREA = "0"
meSUBFUNC = "0"
meBatches = 0
veBatches = 0
meComments = ""
end if
 
Session variables use temporary browser cookies that, by default, expire in 20 minutes.
 
To add to Sheco's comment, you can set the session timeout to a longer/shorter time within IIS directly. If you need to have values that will hold for an indeterminate period of time, though, you might consider something other than session variables.

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
To also add, you can change the timeout for your application with:

Code:
Session.setTimeout = number of minutes

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top