Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Names of Logged-in users 5

Status
Not open for further replies.

schase

Technical User
Sep 7, 2001
1,756
0
0
US
We want to show in a cell the UserID's of the users currently logged-in. and have it auto log-out when they close the browser or after like 20 minutes.

Which is the best way to accomplish this?

Either make a field update in a table to Online - then display the ones that = "online"

or another way?
 
schase,
I'm not sure who's reply you're specifically replying to, however, did you enter the code in the session_onend for the global.asa file? That is what will trigger the number to be reduced or named to be takin out of the list when the session ends.

If Application("userCount") is your variable holding how many people are logged online at one time, then use this in the global.asa file...


---Global.asa------------------

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnEnd
Application(&quot;userCount&quot;) = Application(&quot;userCount&quot;) - 1
End Sub
</SCRIPT>


Hope this helps...
-Ovatvvon :-Q
 
oh sorry, was responding to Link

on the session on end

I have this



sub Session_OnEnd()
dim sql,con
set con=server.createObject(&quot;ADODB.Connection&quot;)
con.open connectionString
sql=&quot;UPDATE Membersragol SET online_status=0 WHERE UserID=&quot;'& session(&quot;MM_Username&quot;) & &quot;'&quot;
con.execute sql
set con = nothing
end sub

And I know MM_Username carries on to another page (I call for it on another page).

But nothing
Logging in part works, but the session OnEnd will not accomplish it's task.
 
Everyone has excellent suggestions. I thought I might add to some.

Sessions are the best way to maintain which users are logged in and which are not. There is a Session Object that you can download for a 30Day trial.

Go Here.

Now, I like this Session Object because it does a couple of things. It tracks the Session Data in a Database. Duh! But it also keep track of the Expiration Time of Session Information automatically for you.

Add the Session Object to the Global.ASA. This will keep track of Session Start and End For you. The load on the server is minimal because it is only one object being stored per user. Then, with this object, on Session and Application Close, you can clean the Session Table, which logs users out.

Below is a sample of what my Global.asa file looks like with this Session Object.

<OBJECT ID=&quot;AppSession&quot; Runat=&quot;Server&quot; SCOPE=&quot;Application&quot; ProgID=&quot;Sessions.CSession&quot;></OBJECT>
<OBJECT ID=&quot;oSession&quot; Runat=&quot;Server&quot; SCOPE=&quot;Session&quot; ProgID=&quot;Sessions.CSession&quot;></OBJECT>

<!--#Include File = &quot;Includes/DataConn.asp&quot;-->

<SCRIPT RUNAT=&quot;SERVER&quot; LANGUAGE=&quot;vbscript&quot;>
Sub Application_onStart()
AppSession.Init &quot;AppSessionVariable&quot;, cDSN, cUserName, cPassword, cConnectionString, &quot;&quot;, &quot;TRIAL_ID_HERE&quot;
End Sub

Sub Application_onEnd()
'Code will cleanup the Session Table
AppSession.DeleteSession
AppSession.DeleteExpiredSessions
End Sub

Sub Session_onStart()
'Set Up the Session Object
Dim sUserSession 'As String
sUserSession = Request.Cookies(&quot;fWSession&quot;)
oSession.Init sUserSession, cDSN, cUserName, cPassword, cConnectionString, &quot;&quot;, &quot;TRIAL_ID_HERE&quot;
End Sub

Sub Session_onEnd()
oSession.DeleteSession
End Sub

</SCRIPT>


oSession and AppSession are available to my project throughout to add and remove data as I please. Works like a charm. Hope this helps.

Osie Brown
 
hi, i have the same problem as schase... my session_onstart did work but not for session_onend when i close the application. for my case, i want to track the logout time but cannot. Is it because of the OS i am using as i am using win xp??
 
On the Session_OnEnd subs.

Like someone said before, the session_onend won't fire until the session either times out or is canceled explicitly with a session.abandon.

This means that if i log into the site, and then leave by either following a link or typing in a new address, my session object will wait until the session timeout before it will try to run the onend command. But everytime I load a page anywhere in the application (the entire web site) it will restart my 20 minute time limit.
I have done what you are talking about ziyun, and it does work like they have it listed above, even in XP. But again, if you don't explicitly cancel the session, then it doesn't always happen right away. And because the session is a server object and not a client, then it doesn't matter that the client closed out the browser becuase it doesn't have to pass that info on to the server.

But there is a whole new topic on this I would like to discuss. Using the LDAP or a application server like Site Server 3.0 to track the online users. It can store the info into the server memory in dynamic values, that are not stored on the web server in session objects, and can be queried through a DB server or the web page. Anyone got any opinions on the pros and cons of the AUO or LDAP?
 
My difficulty was it was not firing irregardless of waiting beyond 20 min or abandoning session. &quot;Insert witty remark here&quot;

Stuart
 
u can try this instead of doing session_onend() to track the logout time of the visitors:

<script language=&quot;JavaScript&quot;>

function exit() {
'the coding u want... e.g.
alert(&quot;hello!&quot;);
}

</SCRIPT>

'call the function exit() when u close the application
<BODY onunload = &quot;exit()&quot;>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top