Handle Session Timeout And Lost MemberID

From: Edward Rothwell (edward.rothwell_at_hale-it.co.uk)
Date: 12/06/04


Date: Mon, 06 Dec 2004 04:14:12 -0800

I have a web site where once a user has logged on I store
their MemberID in a global variable in the global.asa file.

Then in other pages I find out which member I am dealing
with by looking at this variable, ie:

<%
Private lgMemberID

  lgMemberID = Session.Contents("MemberID")

%>

I then use this variable to query a database...

Sub WriteMessages()
Dim strFirstName
Dim strSurname
Dim bPhone
Dim bCard
Dim bEMail
Dim strSQL
Dim rs

  strSQL = "{CALL qGetMessages (" & lgMemberID & ")}"

  Set rs = Server.CreateObject("ADODB.Recordset")
  rs.Open strSQL, conn, 3, 3

  Do Until rs.EOF
    strFirstName = rs("ContactFirstName")
    strSurname = rs("ContactSurname")
    bPhone = rs("Phone")
    bCard = rs("Card")
    bEMail = rs("EMail")

    With Response
      .Write "<TR>" & vbcr
      .Write "<TD width=160>" & strFirstName & " " & strSurname &
"</TD>" & vbcr
      .Write "<TD align='center' width=100>"
      If bPhone Then .Write "<IMG SRC='images/yes.gif' ALT='' BORDER=0>"
      .Write "</TD>" & vbcr
      .Write "<TD align='center' width=100>"
      If bCard Then .Write "<IMG SRC='images/yes.gif' ALT='' BORDER=0>"
      .Write "</TD>" & vbcr
      .Write "<TD align='center' width=100>"
      If bEMail Then .Write "<IMG SRC='images/yes.gif' ALT='' BORDER=0>"
      .Write "</TD>" & vbcr
      .Write "<TD width=23><A HREF='http://?'>Edit</A></TD>" & vbcr
      .Write "<TD width=23><A HREF='http://?'>Delete</A></TD>" & vbcr
      .Write "</TR>" & vbcr
    End With
    rs.MoveNext
  Loop

  rs.Close
  Set rs = Nothing

End Sub

I want to know how to professionally handle the 'time-out' of the
session.
At the moment when the app. times out Session.Contents("MemberID")
equals 0.
Which means I get an error:

"ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record."

I don't really want to handle the BOF/EOF error directly as this is just
a symptom of a different problem (the time out).

Would I have to force the user to log in again?
Increase the time out?
How do other people do this??

I also don't see how appropriate it would be to increase the timeout to,
say 2 hours. When the site generates large amounts of traffic then
keeping 100s of sessions live for so long is going to eat too many
resources.

Do other people use cookies to store the memberID instead of a session
variable?
If so - what do they do about people who have cookies blocked?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Relevant Pages

  • Re: Handle Session Timeout And Lost MemberID
    ... >I have a web site where once a user has logged on I store ... > their MemberID in a global variable in the global.asa file. ... > Dim strFirstName ... > Do other people use cookies to store the memberID instead of a session ...
    (microsoft.public.inetserver.asp.general)
  • Re: New issue with "With" statement
    ... Set memberid = F.Offset ... Dim uniqueidsopen As Range ... With Sheets("Payment Sales Master") ... With Sheets("Open Transactions") ...
    (microsoft.public.excel.programming)
  • Re: PK & FK problems in data consolidation
    ... Dim r As DAO.Recordset ... So we will not show like affiliation form in the church secretary. ... You can automatically create the concatenated MemberID in the BeforeInsert event of the Members ... Set rst = db.OpenRecordset ...
    (microsoft.public.access.formscoding)
  • RE: Revisiting "New issue with "With" statment" post from 6/7/07
    ... With Sheets("Member ID Report Master") ... Set memberid = F.Offset ... Dim uniqueidsopen As Range ...
    (microsoft.public.excel.programming)
  • Re: getImage and VBA Callback
    ... Word MVP web site http://word.mvps.org ... Private Declare Function GdipCreateBitmapFromFile Lib ... IPicture Dim uGdiInput As GdiplusStartupInput ...
    (microsoft.public.excel.programming)