Im making a forum which displays the names of all online users by using "SELECT tblUsers.alias FROM tblUsers WHERE tblUsers.status='online'". But then I need to change there status when they close the browser or the session timesout. Is there another way around it than using session_onEnd because I heard that isnt very reliable, also if i do use this can I still get session variables inside the onEnd function?
To end a session when the user closes the browser window you need to add a new page to your site. For example, add a page named sessEnd.asp. This page should need only one line of code:
<%Session.Abandon%>
You can also add some extra html here and use it as the target of a Logout link from anywhere in your site. From a link the page will display. From the code example below, it will not show, but will execute.
Using Javascript force a post to this page when the user closes the browser or navigates away from your site. Here is a function that will do it.
<script language="JavaScript">
<!--
function ForceSubmit(){
The Session_OnEnd event occurs whenever Session.Abandon is explicitly called or when the current session times out due to inactivity. This is usually 20 minutes by default.
Bookmarks