This topic is locked
[SOLVED]

 Session timeout issue

8/25/2009 4:59:24 PM
ASPRunnerPro General questions
author

I just moved my database to an MSSQL Server 2005 platform and added login pages and now I am having frequent timeout issues. I've gone here: http://www.xlinesoft.com/articles/session_expired.htm many times, but my windows XP does not appear to have the same application configuration setup, so that does not work.
Is there some code I can tweak in the ASPRunnerPro security files to change the timeout or session variables or whatever?
If it ain't one thing it's the other...
Thanks.

J
Jane 8/26/2009

Hi,
Session timeout can be changed on the server side only:

http://xlinesoft.com/articles/session_expired.htm

501351 8/26/2009



Hi,
Session timeout can be changed on the server side only:

http://xlinesoft.com/articles/session_expired.htm


Thanks. I contacted my webhost and they are working on it.

501352 8/26/2009



Thanks. I contacted my webhost and they are working on it.


Jane: Thanks. I passed that info to my webhost and below is their reply. I think the only thing I need now is to know where I should place the session timeout script:

<%

Session.Timeout=5

%>
Dear Robert,

Thank you for contacting our technical support team.
I have assigned your domain into dedicated application pool - it should prevent sporadic session closure. However, also, you should configure your asp scripts to increase session timeout. If you want to set a timeout interval that is longer than the default, use the Timeout property.
The example below sets a timeout interval of 5 minutes:

<%

Session.Timeout=5

%>
Should you have any further questions, feel free to contact us anytime. We are available 24/7.

J
Jane 8/27/2009

Hi,
you can add your code in the generated include/dbcommon.asp file.

501353 8/27/2009



Hi,
you can add your code in the generated include/dbcommon.asp file.


Thanks, Jane. I would really appreciate it if you could tell em where to put that bit of code.
Here is the contents of my dbcommon.asp file:
<%@codepage=1252%>

<%
cCharset = "Windows-1252"
response.Charset=cCharset
dDebug=false

useAJAX=true

suggestAllContent=true
Session.LCID = 1033

session.codepage=1252
dSQL=""

bSubqueriesSupported=true
strDatabaseType = "MS SQL SERVER"
Set tables_data = CreateObject("Scripting.Dictionary")

Set field_labels = CreateObject("Scripting.Dictionary")

Set arrAvailableEvents = CreateObject("Scripting.Dictionary")
dim dbConnection
%>

<!--#include file="locale.asp"-->

<!--#include file="events.asp"-->

<!--#include file="commonfunctions.asp"-->

<!--#include file="dbconnection.asp"-->

<!--#include file="dal_source.asp"-->

<!--#include file="aspfunctions.asp"-->

<%
dim conn
Const FORMAT_NONE = ""

Const FORMAT_DATE_SHORT = "Short Date"

Const FORMAT_DATE_LONG = "Long Date"

Const FORMAT_DATE_TIME = "Datetime"

Const FORMAT_TIME = "Time"

Const FORMAT_CURRENCY = "Currency"

Const FORMAT_PERCENT = "Percent"

Const FORMAT_HYPERLINK = "Hyperlink"

Const FORMAT_EMAILHYPERLINK = "Email Hyperlink"

Const FORMAT_FILE_IMAGE = "File-based Image"

Const FORMAT_DATABASE_IMAGE = "Database Image"

Const FORMAT_DATABASE_FILE = "Database File"

Const FORMAT_FILE = "Document Download"

Const FORMAT_LOOKUP_WIZARD = "Lookup wizard"

Const FORMAT_PHONE_NUMBER = "Phone Number"

Const FORMAT_NUMBER = "Number"

Const FORMAT_HTML = "HTML"

Const FORMAT_CHECKBOX = "Checkbox"

Const FORMAT_CUSTOM = "Custom"
Const EDIT_FORMAT_NONE = ""

Const EDIT_FORMAT_TEXT_FIELD = "Text field"

Const EDIT_FORMAT_TEXT_AREA = "Text area"

Const EDIT_FORMAT_PASSWORD = "Password"

Const EDIT_FORMAT_DATE = "Date"

Const EDIT_FORMAT_TIME = "Time"

Const EDIT_FORMAT_RADIO = "Radio button"

Const EDIT_FORMAT_CHECKBOX = "Checkbox"

Const EDIT_FORMAT_DATABASE_IMAGE = "Database image"

Const EDIT_FORMAT_DATABASE_FILE = "Database file"

Const EDIT_FORMAT_FILE = "Document upload"

Const EDIT_FORMAT_LOOKUP_WIZARD = "Lookup wizard"

Const EDIT_FORMAT_HIDDEN = "Hidden field"

Const EDIT_FORMAT_READONLY = "Readonly"
Const EDIT_DATE_SIMPLE = 0

Const EDIT_DATE_SIMPLE_DP = 11

Const EDIT_DATE_DD = 12

Const EDIT_DATE_DD_DP = 13
Const MODE_ADD = 0

Const MODE_EDIT = 1

Const MODE_SEARCH = 2

Const MODE_LIST = 3

Const MODE_PRINT = 4

Const MODE_VIEW = 5

Const MODE_INLINE_ADD = 6

Const MODE_INLINE_EDIT = 7
Const LOGIN_HARDCODED = 0

Const LOGIN_TABLE = 1
Const ADVSECURITY_ALL = 0

Const ADVSECURITY_VIEW_OWN = 1

Const ADVSECURITY_EDIT_OWN = 2

Const ADVSECURITY_NONE = 3
Const ACCESS_LEVEL_ADMIN = "Admin"

Const ACCESS_LEVEL_ADMINGROUP = "AdminGroup"

Const ACCESS_LEVEL_USER = "User"

Const ACCESS_LEVEL_GUEST = "Guest"
Const DATABASE_MySQL = "MYSQL"

Const DATABASE_Oracle = "ORACLE"

Const DATABASE_MSSQLServer = "MS SQL SERVER"

Const DATABASE_Access = "ACCESS"
Const RTE_BASIC = "BASIC"

Const RTE_FCK = "FCK"

Const RTE_INNOVA = "INNOVA"
Const ADD_SIMPLE = 0

Const ADD_INLINE = 1

Const ADD_ONTHEFLY = 2
Const LIST_SIMPLE = 0

Const LIST_LOOKUP = 1
Const LCT_DROPDOWN = 0

Const LCT_AJAX = 1

Const LCT_LIST = 2

Const LCT_CBLIST = 3
Const LT_LISTOFVALUES = 0

Const LT_LOOKUPTABLE = 1
strLeftWrapper="["

strRightWrapper="]"
cLoginTable = "C270584_admin.Users"

cUserNameField = "UserName"

cPasswordField = "Password"

cUserGroupField = "UserName"

cEmailField = "x_Email"
cFrom = "me@gmail.com"

cSmtpServer = "mail.mysite.com"

cSmtpPort = "localhost"

cSMTPUser = "name@mysite.com"

cSMTPPassword = "password"
gPermissionsRefreshTime=0

gPermissionsRead=false
set includes_js=server.CreateObject("Scripting.Dictionary")

set includes_jsreq=server.CreateObject("Scripting.Dictionary")

set includes_css=server.CreateObject("Scripting.Dictionary")
Set myRequest = CreateObject("Scripting.Dictionary")

Set myRequestFiles = CreateObject("Scripting.Dictionary")

parse=0
set conn=db_connect()

set dbConnection=conn
' determine current page

if SESSION("UserID")="" then

allowGuest=guestHasPermissions()

dim path,pos,file

path=request.ServerVariables("PATH_INFO")

pos=instrrev(path,"/")

file=lcase(mid(path,pos+1))

if allowGuest and file<>"login.asp" and file<>"remind.asp" and file<>"register.asp" then

SESSION("UserID")="Guest"

SESSION("GroupID")="<Guest>"

SESSION("AccessLevel")=ACCESS_LEVEL_GUEST

if asp_functionexists("AfterSuccessfulLogin") then

AfterSuccessfulLogin "","",CreateDictionary()

end if

end if
function db_connect()

set dbConnection = server.CreateObject("ADODB.Connection")

dbConnection.ConnectionString = strConnection

dbConnection.Open

set db_connect=dbConnection

end function

function AddTableWrappers(strName)

if mid(strName,1,1)=strLeftWrapper then

AddTableWrappers = strName

exit function

end if

dim arr

arr=split(strName,".")

ret=strLeftWrapper & arr(0) & strRightWrapper

if ubound(arr)>0 then ret=ret & "." & strLeftWrapper & arr(1) & strRightWrapper

AddTableWrappers = ret

end function
function db_upper(dbval)

db_upper = "upper(" & dbval & ")"

end function
function AddFieldWrappers(strName)

if mid(strName,1,1)=strLeftWrapper then

AddFieldWrappers = strName

else

AddFieldWrappers = strLeftWrapper & strName & strRightWrapper

end if

end function

function FieldNeedQuotes(rs,field)

ttype=dbfieldtype(rs,field)

if ttype=20 or ttype=128 or ttype=11 or ttype=6 or ttype=14 or ttype=5 or ttype=3 or ttype=131


or ttype=4 or ttype=2 or ttype=16 or ttype=21 or ttype=19 or ttype=18 or ttype=17 or ttype=139 then

FieldNeedQuotes = false

else

FieldNeedQuotes = true

end if

end function

function db_addslashes(str)

db_addslashes = asp_str_replace("'","''",str)

end function

function db_datequotes(val)

db_datequotes = "convert(datetime,'" & val & "',120)"

end function

function db_stripslashesbinary(str)

db_stripslashesbinary=str

end function
function db_fieldtype(lhandle,fname)

Dim i

for i=0 to db_numfields(lhandle)-1

if db_fieldname(lhandle,i)=fname then

ttype=db_fieldtypen(lhandle,i)

db_fieldtype = ttype

exit function

end if

next

db_fieldtype = ""

end function

function db_numfields(lhandle)

db_numfields = lhandle.Fields.Count

end function
function db_fieldname(lhandle,fnumber)

db_fieldname = lhandle.Fields(fnumber).Name

end function
function db_fieldtypen(lhandle,fnumber)

dbfieldtypen = lhandle.Fields(fnumber).Type

end function
function date2str(val)

if isnull(val) then

date2str=""

exit function

end if

if isdate(val) then

date2str = CStr(year(val)) & "-" & CStr(month(val)) & "-" & CStr(day(val)) &


" " & CStr(hour(val)) & ":" & CStr(minute(val)) & ":" & CStr(second(val))

exit function

end if

date2str=""

end function
%>

C
clig 8/27/2009



Thanks, Jane. I would really appreciate it if you could tell em where to put that bit of code.
Here is the contents of my dbcommon.asp file:
<%@codepage=1252%>

<%

Session.Timeout=5
cCharset = "Windows-1252"

...
seems odd though as the default is 20 minutes... that ISP must have had an awful short server config prior to extend it to 5 minutes....

501354 9/14/2009



Hi,
you can add your code in the generated include/dbcommon.asp file.


Jane: I still don't know where in the dbcommon.asp file to add the code to change the session timeout to 20 minutes. Please advise. Sorry to be such an ignoramous. Thanks.

J
Jane 9/15/2009

Hi,
find this line:

cCharset = ...



and add following code just after:

Session.Timeout=5

501355 9/15/2009



Hi,
find this line:
and add following code just after:



Thanks, Jane. I added the code and but changed it to 20 instead of 5. I asked my users to see if they continue to get bumped out. Thanks again.

501356 9/15/2009

Nope. That didn't do the trick. I'm going to work with the webhost, Hostexcellence. Gotta be something on their end?

Sergey Kornilov admin 9/15/2009

To the best of my knowledge setting session timeout from ASP code won't work in 95% of cases. It did work in earlier version of IIS.
Your web host needs to fix this. Two articles to start with:

http://xlinesoft.com/articles/session_expired.htm
http://www.webcheatsheet.com/ASP/asp_troubleshooting.php

Section 'Application loses session variables sporadically'