Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Notifying a user when the session timeouts
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Divers
Thread ID:
00228729
Message ID:
00228934
Vues:
11
I just noticed that my code snippet didn't show up due to the script delimiters. For those of you who are interested it was:

If Len(Session("strConn")) = 0 Then
Response.Redirect "timeout.asp"
End If

>Quite true. We use the LEN() function because not only does it tell us if the user's session has timed out, it also serves to prevent users from entering the site in the middle since if they don't use the start page, the connection string doesn't get set.
>
>>FYI, you can also use isObject(Session) to see if the Session Object still exists. Thanks for the info. I was afraid of that.
>>
>>>>>>What is the best way to redirect a user to another page when their session timeouts?
>>>>>
>>>>>Why not use Response.Redirect if session variables are empty?
>>>>
>>>>Because I don't want to have to check session variables everytime a user clicks a button or link. I have been trying to use the Session_Onend event, but with no luck. It doesn't seem to do anything. Have you used this?
>>>
>>>Because ASP cannot respond to events, Session_OnEnd doesn't really help with this. Testing a Session variable is pretty much your only option. Since we store the ADO connection string to a Session variable, at the top of every page we test it's length using LEN(). If it evaluates to zero, we know the session has timed out and we redirect them to a page that tells them what happened. Our code looks like this:
>>>
>>><%
>>>If Len(Session("strConn")) = 0 Then
>>>Response.Redirect "timeout.asp"
>>>End If
>>>%>
>>>
>>>We keep the code in an include file and we've added the include reference into the default ASP page template so it's always there whenever we create a new ASP page.
"It is an important and popular fact that things are not always what they seem. For instance, on the planet Earth, man had always assumed that he was more intelligent than dolphins because he had achieved so much -- the wheel, New York, wars and so on -- whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man -- for precisely the same reasons." - Douglas Adams
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform