How To Find Out When User Has Left My Site

Results 1 to 3 of 3

Thread: How To Find Out When User Has Left My Site

  1. #1
    Join Date
    Dec 1969

    Default How To Find Out When User Has Left My Site

    If a user leaves the secure area of my site without logging off (ie. closes browser or leaves for different site), how do I determine this so I can manually Log them off? I don't want to allow the same user to log in on two different machines so if they're already listed as "logged in" in the database I don't allow them to log in. I can't seem to rely on code in the Session_OnEnd of my Global.asa to log them off because this code doesn't run until the session times out 20 minutes later. Any help would be greatly appreciated. Thanks.

  2. #2
    Join Date
    Dec 1969

    Default RE: How To Find Out When User Has Left My Site

    I don&#039;t think you can. After all, ASP relies on requests from the browser and if they stop being made then it sits and waits for the session to time out, hence the reason some people don&#039;t like using session variables, they hang around until the session is abandoned through code by the developer ( if the user is active ) or the session times out ( if the user has left the site ).<BR>You could try placing some javascript in the unload event of the page, but if they close the browser even that doesn&#039;t get triggered.<BR>Just to make matters worse, the session_onend is notoriously buggy and sometimes doesn&#039;t work either ( though having never used it I don&#039;t know from personal experience ).<BR><BR>Unfortunately there doesn&#039;t appear to be any easy solution.<BR><BR>Hmmm... just had an idea, session id&#039;s are unique so why not store that in the database against the user and if he/she then tries to log in on another machine it could inform them that their previous session was not logged out correctly and that their new login will overwrite their previous session etc etc. Get the idea?<BR><BR>--<BR><BR>AS

  3. #3
    Join Date
    Dec 1969

    Default Good answer! <eop>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts