Link to home
Start Free TrialLog in
Avatar of wunyu
wunyu

asked on

detecting idle session or closed window

Hi Experts,

I would like to know how to determine when a session is idle for a period of time (so I can kill their idle connection) or a user has closed the browser (without logging out first).  My website is using asp with vbscript and has a SQl server backend that keeps track of the current log in sessions.

Thanks!!!
SOLUTION
Avatar of frodoman
frodoman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wunyu
wunyu

ASKER


>> IIS handles this based on your server's configuration - I believe 20 minutes is the default value.

Where do I find this information or where do I configure this?

Also, in yahoo mail, for example, if a user logs into their email account and then copies down that URL, if they close the browser and open another browser and goes to that same URL, yahoo asks for a password.  How did yahoo know that the user had closed the browser or how do they know when to expire a session is more appropriate.

Thanks.
Hi,

you can detect/set this in your script:-

<html>
<body>

<%  
response.write("<p>")
response.write("Default Timeout is: " & Session.Timeout & " minutes.")
response.write("</p>")

Session.Timeout=30

response.write("<p>")
response.write("Timeout is now: " & Session.Timeout & " minutes.")
response.write("</p>")
%>

</body>
</html>
Avatar of wunyu

ASKER

Hm ... but on some websites, when I close the window, a smaller window pops up.  Does this show that it's possible to determine when a window gets closed?

For example, if you go to www.time.com and you close the window, a smaller window pops up and asks you to subscribe.

How do they determine when they've closed the larger window?  Thanks.
They put a javascript function in the onUnload event.  <body onUnload=DoSomeFunction();>

This isn't bad, but don't think it's foolproof either.  It only works if javascript is turned on.  It only works if you try to close the window (i.e.: does *not* work if you press back button the leave the site), etc.
HTTP is what is called a stateless session i.e. browser requests a page, server serves that page to the browser (client), and then forgets about them... i.e. the browser will be identifiable via session info at the server (when the browser makes its next call within the timeout period)... but the server can't contact the browser independantly... unless you use a form of web service that is.

Javascript is what most use to detect the window closing as wunyu says... but i don't like that method... i rather log users at a db at the server, thier logon time etc.


P.S. Hope this helps.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OR

just set a variable in the users session that stores the time they logged on and update it using a timer in your pages, and once its timed out or about o you will know - with a bit of jiggery powkery u could do allsorts.

P.S. Don't think there is a simple command for knowing how long a session has left, and there is no way of detecting when a user closes thier browser without using javascript...

alternatively you could have some code sitting in the application object that poles the logged on users and does things accordingly.

P.P.S. Hope this helps.
Daleoran,

Recommend split points:  frodoman { html#9617126 } and Devastated { html#9735831 }

frodoman
Daleoran,

Recommend split points:  frodoman { #9617126 } and Devastated { #9735831 }

frodoman
idd - between us we have given a full answer