Re: Handle Session Timeout And Lost MemberID

From: Sven Pernils (sven.pernils_at_bonetmail.com)
Date: 12/07/04


Date: Tue, 7 Dec 2004 12:48:00 +0100

You might want to create a temporary cookie on the users machine, with some
userCode, and check the cookie on every page user access. With this, you can
even have a track of the user moving around your site.
Yes it involves som coding, but in the long run it pays off.

Sven

"Edward Rothwell" <edward.rothwell@hale-it.co.uk> skrev i meddelandet
news:%23wYkZ042EHA.1392@tk2msftngp13.phx.gbl...
>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: Ticket disappears when browser is closed
    ... be careful - if the cookie is save to the users harddrive - anyone who has access to that directory can grab the cookie and bypass authentication. ... Dim New DatabaseUser ... Dim userData As String = DatabaseUser.UserData ... ByVal PersonID As Integer, ByVal roles As String) ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: DESPERATE: FormsAuthentication Problem
    ... > them in the forms authentication cookie. ... > ' Get ";" delimited string of the user's roles from the database ... > Dim authTicket As FormsAuthenticationTicket = New ...
    (microsoft.public.dotnet.framework.aspnet)
  • DESPERATE: FormsAuthentication Problem
    ... them in the forms authentication cookie. ... from the forms authentication cookie, create a new FormsIdentity object, ... ' Get ";" delimited string of the user's roles from the database ... Dim authTicket As FormsAuthenticationTicket = New ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • DESPERATE: FormsAuthentication Problem
    ... them in the forms authentication cookie. ... from the forms authentication cookie, create a new FormsIdentity object, ... ' Get ";" delimited string of the user's roles from the database ... Dim authTicket As FormsAuthenticationTicket = New ...
    (microsoft.public.dotnet.framework.aspnet)
  • Keeping a session alive when accessing an ASP page with .Net code
    ... The problem is that the site uses session variables ... back an ASPSESSIONID cookie, I store it in a Cookie object, and keep passing ... Dim objHTTPRequest As HttpWebRequest ...
    (microsoft.public.dotnet.framework.aspnet)