|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Global.asa /Session Variables
hi there, im new here, and hopefully someone can help me
![]() i have a logon page, i create session variables for every person who logs on, but when their session times out, i want to redirect them (or have a popup window) that tells them that they have been logged off, but i have no success.... this is my global.asa: <script language="vbscript" runat="server"> Sub Session_OnEnd Response.Redirect "loggedout.asp" End Sub </script> but it doesnt work, i set the timeout to 1 minute, and i lose the session variables, but i cant seem to redirect them to the loggedout page!!! please help thanks
__________________
"Morgoth i Cried All Hope is Gone But i Swear REVENGE Hear my Oath!!" |
|
#2
|
||||
|
||||
|
hi,
in the global.asa file you should have something like this: Code:
<SCRIPT LANGUAGE=VBScript RUNAT=Server> SUB Session_OnStart Session.TimeOut = 90 END SUB </SCRIPT> After that you need to set your session variable you want to check. Then at the top of each page have an include file which checks to see if that variable has been cleared. If so then force a re-direct to another page. Code:
If Session("StrUsername") = "" Then
Response.Redirect("Expirepage.asp")
End If
Kong. |
|
#3
|
|||
|
|||
|
thanks, but i had a if staement like that already...
if session("name") = "" then call javascript function() end if but it isnt happening!!! lets say my timeout is 2 minutes, i sit and wait for 5 minutes.. nothing happens... only then if a perform an action... does it call that javascriptfunction... i put that my global.asa file looks exactly like you have it... ???? |
|
#4
|
||||
|
||||
|
Hi,
Just out of interest what happens if you replace your line where you call a javascript function and put instead just Response.Redirect("page.html"). By keeping all the code in ASP you should be able to confirm whether or not the session timeout is working. Kong. |
|
#5
|
|||
|
|||
|
hhmm... it still doesnt happen dynamically, it only happens after the timeout has passed and i perform an action.
wouldnt the global.asa pic it up, and cant i put a redirect in there?? thanks |
|
#6
|
||||
|
||||
|
Hi,
with the above code the session.timeout is not checked until the user performs a request to a page, then it will go off and check. I don't think the global.asa can do what your suggesting. To make something pop-up dynamically would require a lot more work.. then just the above code. I`ll have a scout about and see what I can find as I would be quite interested in being able to do that. Kong. |
|
#7
|
|||
|
|||
|
ive tried timers, but that doesnt work seeing as i want to measure INACTIVITY... exactly what sessions do...
thanks for the trouble |
|
#8
|
|||
|
|||
|
response.redirect must go through the client browser, which may be long gone by the time the session.onend event fires (20 minutes of no activity by default). If the browser isn't there anymore the logout.asp page will never be hit, the server can't redirect there by itself.
|
|
#9
|
|||
|
|||
|
ive found something which avoids using session variables...
<html> <head> <script language="JavaScript"> var a, b; function A() { b = 0; a = window.setInterval("c()",1000); } function c() { b++; document.d.e.value = b; if (b == "5") {window.location = "www.page.html"}; } function f() { b = 0; } </script> </head> <body onLoad="A();" onKeyPress="f();" onMouseMove="f();"> <form name="d"> <input type="text" name="e" value=""> </form> </body> </html> a guy named Vosk.. thanks to him... this works perfectly. |
|
#10
|
|||
|
|||
|
hey the code is straight forward..do you want me to explain it??
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Global.asa /Session Variables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|