Re: session variable inconsistency by Geoff
Geoff
Mon Jun 21 14:51:51 CDT 2004
I think I found the source of the problem:
Last week I was experimenting with assigning more than one worker process to
the web garden under the application pool properties in IIS 6.0 (because I
had an incident where IIS stopped serving ASP pages, possibly due to a bug
in the jet database engine when using ODBC). From my limited understanding
of IIS it seems that during one session, multiple worker processes may be
assigned and that they don't have access to the session variable assigned to
another process; hence the reason for being forwarded to the login.html
page. I guess the occassional error on the main.asp page is a separate
matter.
Anyway, I switched back to allowing only one worker process and the problem
seems resolved.
Geoff
"Geoff Winsor" <geoff@brinkman.mbb.sfu.ca> wrote in message
news:cb7icp$jmc$1@morgoth.sfu.ca...
> Hi James,
> Here is the code for login.html, verify.asp (sets the session variable),
> main.asp, a method in the functions.inc file (which contains a line
referred
> to in the previous error message) and a snippet of code from options.asp
> that checks to see if the authentication variable is set. I hope it is not
> too messy too read.
>
> The important code for the login page:
>
> <form action=verify.asp method=Post
> enctype="application/x-www-form-urlencoded" name=start
> Onsubmit="return validateForm(this);">
> <table border=0 cellpadding=0 width="22%"
> style='width:22.0%;mso-cellspacing:
> 1.5pt;mso-padding-alt:2.25pt 2.25pt 2.25pt 2.25pt'>
> <tr><td width="47%" style='width:47.0%;padding:2.25pt 2.25pt 2.25pt
> 2.25pt'>
> <p class=MsoNormal>Username: </p>
> </td> <td width="53%" style='width:53.0%;padding:2.25pt 2.25pt 2.25pt
> 2.25pt'>
> <p class=MsoNormal><INPUT TYPE="text" SIZE="15" NAME="username"></p>
> </td></tr><tr>
> <td width="47%" style='width:47.0%;padding:2.25pt 2.25pt 2.25pt
2.25pt'>
> <p class=MsoNormal>Password:</p></td>
> <td width="53%" style='width:53.0%;padding:2.25pt 2.25pt 2.25pt
2.25pt'>
> <p class=MsoNormal><INPUT TYPE="password" SIZE="15"
NAME="password"></p>
> </td></tr><tr>
> <td colspan=2 style='padding:2.25pt 2.25pt 2.25pt 2.25pt'>
> <p class=MsoNormal><INPUT TYPE="submit" ACTION="verify.asp"
> METHOD="Post" NAME="submit"
> ACTION=verify.asp METHOD=Post></p>
> </td></tr></table>
> </form>
>
> The asp code for the verify.asp page:
>
> <%
> SQL ="SELECT * FROM Researcher WHERE StrComp('" &
Request.Form("username")
> & "', ResearcherID, 0)=0 AND StrComp(UserPassword, '" &
> Request.Form("password") & "', 0)=0"
> SET DbObject = Server.CreateObject ("ADODB.Connection")
> DbObject.Open "DSN=pseudoCAP1;UID=;PWD="
> set rs = server.createobject("adodb.recordset")
> SET Rs = DbObject.Execute (SQL)
> If Rs.EOF Then
> Session("Authenticated") = 0
> Response.Redirect ("unsuccessfulLogin.htm")
> Else
> Session("Authenticated") = 1
> Session("user") = Request.Form("username")
> End If
> rs.close
> set rs = nothing
> DbObject.Close
> set DbObject = nothing
> response.redirect "main.asp"
> %>
>
> The main.asp page (does not check for a login but provides links to pages
> that do need an authentication):
>
> <%@ Language=VBScript %>
> <SCRIPT LANGUAGE="JavaScript" src="include/help_windows.js"></SCRIPT>
> <!--#INCLUDE FILE="../include/functions.inc"-->
> <%
> 'Declare ADOVBS constants
> Const adOpenStatic = 3
> Const adLockOptimistic = 3
> Const adCmdText = &H0001
> SQL = "SELECT * FROM Researcher R LEFT OUTER JOIN Institution I ON
I.iName
> = R.Institution AND I.Street = R.Street AND I.City = R.City WHERE
> ResearcherID = '" & Session("user") &"'"
> SET DbObject = Server.CreateObject ("ADODB.Connection")
> DbObject.Open "DSN=pseudoCAP1"
> set RS = server.createobject("adodb.recordset")
> RS.Open SQL, DbObject, adOpenStatic, adLockOptimistic, adCMDText
> %>
> <p align="center"><form METHOD="post" NAME="query"
> ACTION="../UpdatesSearchResultsU.asp" target=_blank
> onMouseOut="MM_swapImgRestore()"
> onMouseOver="MM_swapImage('history','','/images/viewHistory2.gif',1)"
> onSubmit="return validRange(this);">
> <input id="SearchStr1a" type="hidden" name="SearchStr1a" value="">
> <input id="SearchStr1b" type="hidden" name="SearchStr1b" value="">
> <input id="SearchStr1a_m" type="hidden" name="SearchStr1a_m"
value="">
> <input id="SearchStr1a_d" type="hidden" name="SearchStr1a_d"
value="">
> <input id="SearchStr1a_y" type="hidden" name="SearchStr1a_y"
value="">
> <input type="hidden" name="ord1" value="date_updated">
> <input id="SearchStr1b_m" type="hidden" name="SearchStr1b_m"
value="">
> <input id="SearchStr2a_d" type="hidden" name="SearchStr1b_d"
value="">
> <input id="SearchStr2a_y" type="hidden" name="SearchStr1b_y"
value="">
> <input id="SearchStr4" type="hidden" name="SearchStr4"
> maxlength="255">
> <input id="viewRecent" type="hidden" name="viewRecent"
value="false">
> <input id="Field2" type="hidden" name="Field2" value="Participant">
> <input id="SearchStr2" type="hidden" name="SearchStr2"
> value="<%=getField(RS, "rLastName")%>">
> <input name="history" type="image" border="0"
> src="/images/viewHistory.gif" width="224" height="26" alt="View Submission
> History">
> </form></p><p> </p><p>If you have not already logged in, you
will
> have to do so <a href="login.html">here</a>.</p></td></tr></table>
> <%
> rs.Close
> Set rs = Nothing
> DbObject.close
> Set DbObject = Nothing
> %>
> <p> </p>
> </center>
> </BODY>
> </HTML>
>
> A functions.inc file contains this function that is called in the form
above
> and is sometimes returned:
>
> function getField(oRs, fieldIndex)
> Strtemp = oRs(fieldIndex) ### this is the line referred to in
> the error returned in my browser###
> if isnull(strtemp) then
> getField = ""
> else
> getField = Strtemp
> end if
> end function
>
>
> Finally each page linked to from the main.asp page checks for the value of
> the "Authentication" session variable:
>
> <%
> ' Verify that the user has logged in
> If Session("Authenticated") = 0 Then
> Response.Redirect ("login.html")
> End If
> %>
>
> I guess that is it. Thanks.
> Geoff
>
>