|
-
May 3rd, 2001, 03:07 AM
#1
Implementing Online Status
How would I display a list of online users at my ASP site?
Thanks.
Si
-
May 3rd, 2001, 02:14 PM
#2
Black Cat
Load them into a Application array or other data structure when the Session starts, unload them when the Session ends.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
May 4th, 2001, 07:54 AM
#3
Black Cat
I would use a db table to store the current users, and just use ADO to get the list from the table.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
May 4th, 2001, 08:06 AM
#4
How do I know when to remove the user from the db thou?
-
May 4th, 2001, 09:27 AM
#5
Black Cat
When the Session ends (either timeout or if you abandon it if they logout).
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
May 4th, 2001, 07:07 PM
#6
Ok I get that, but how do I do that? do you have any examples? links?
Thanks
si
-
May 5th, 2001, 09:03 PM
#7
Good Ol' Platypus
In GLOBAL.ASA --->
Sub Session_OnEnd
'code here
End Sub
Although I cannot use Global.ASA on my server (EVIL SERVER ) so I don't know too too much about it (just my handy-dandy Wrox ASP books...)
PS>
Where do all of you guys get your ASPs hosted? (for free I mean), because I can only find BRINKSTER (http://www.brinkster.com/) and they aren't that good...
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 6th, 2001, 08:25 AM
#8
Originally posted by Sastraxi
In GLOBAL.ASA --->
Sub Session_OnEnd
'code here
End Sub
I heard of that and still dont know how to use it, does anyone have any help?
-
May 6th, 2001, 08:50 AM
#9
Good Ol' Platypus
Okay.. Then you can set a session variable...
Session("UsersOnline") = 0
Then when somebody logs in, (any ASP page)
Session("UsersOnline") = Session("UsersOnline") + 1
Then you can make an array with all the names of them when they login, although I'm not sure session variables support this.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 6th, 2001, 09:48 AM
#10
So if i put that session varible in the global.asa it will work for all users? how do i tell when I minus one from it thou?
and also its not hte number of users, its a list of user names i want to put.
thanks
si
-
May 6th, 2001, 10:11 AM
#11
Good Ol' Platypus
Code:
Sub Session_OnStart
Session("LIU") = Session("LIU") + 1
End Sub
Sub Session_OnEnd
Session("LIU") = Session("LIU") + 1
End Sub
...in Global.ASA
Then you can do this in the ASP that processes the login:
Code:
<!-- #INCLUDE FILE="adovbs.inc"-->
<%
'CONNECT TO DATABASE.... AND GET TO CORRECT USER & PWD RECORD
oRec("Online") = "YES" '<-----THIS LINE!!!
Response.Redirect "loggedin.asp?usernm=" + Request.Form("nmme")
'IF THE USER/PWD COMBO IS BAD, THEN REDIRECT TO BADLOGIN PAGE
%>
Then, when you want to display the users:
Code:
Sub OutputUsers()
'connect to database....
While Not oRec.EOF
If oRec("Online") = "YES" Then
Response.Write "<A HREF='profile.asp?user=' + oRec("Username") + "'>" + oRec("Username") + "</A>"
End If
Wend
End Sub
'other stuff...
Note that I put in an ANCHOR tag, going to profile.asp, just for some extras.
This is how I am implementing it on my site.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 6th, 2001, 10:13 AM
#12
Good Ol' Platypus
And also when they logout, remember to set ONLINE in oREC to "".
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 6th, 2001, 06:37 PM
#13
Thanks!!
What if the user dosesnt log out thou?
si.
-
May 6th, 2001, 10:29 PM
#14
Good Ol' Platypus
Easy. Exiting the site still causes a Session_OnEnd, so...!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 6th, 2001, 10:30 PM
#15
Good Ol' Platypus
Oh sorry just noticed...
In session_onend that should DECREASE the variable ( - 1)
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 8th, 2001, 03:45 AM
#16
Originally posted by Sastraxi
Oh sorry just noticed...
In session_onend that should DECREASE the variable ( - 1)
hehe Noticed that 
Thanks for the code, Now I need to try it just gotta get IIS working now I also got some code off someone else, that had and array in it, but I havnt tried it yet, If it does I will post the code
Cheers all, youve been a Help!!!
Simon
-
May 8th, 2001, 02:57 PM
#17
Good Ol' Platypus
Just some other thoughts.
1. You shouldn't put +1 in the Session_OnStart, add 1 when they login.
2. Make "LIU" (LoggedInUsers) an Application Level variable.
3. Make another Session variable that you will set, "LOGGEDOUT", in the logout page. If "LoggedOut" isn't "YES" then decrease the LIU by 1 ( - 1 ) in Session_OnEnd.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 9th, 2001, 02:06 AM
#18
Heres that code that I was talking about... it also holds the IP adresses too...
Code:
''************* GLOBAL.ASA: ******************************
Sub Application_OnStart
Dim usersArray(100), usersID(100)
Application("usersArray")=usersArray
Application("usersID")=usersID
End Sub
''**********************************************************
Sub Session_OnStart
Session.Timeout = 50
Session("svr") = Request.ServerVariables("SERVER_NAME")
Session("ServiceInstance") = "1"
Dim usersArray, usersID, x, doesExist, myZ
doesExist=False
usersArray=Application("usersArray")
usersID=Application("usersID")
For x=0 To 99
If usersArray(x)=Request.ServerVariables("remote_host") Then
doesExist=True
Exit For
End If
Next
If Not(doesExist) Then
For x=0 To 99
If usersArray(x)="" Then
Exit For
End If
Next
If (x<100) Then
usersArray(x)=Request.ServerVariables("remote_host")
usersID(x)=Session.SessionID
Application("usersArray")=usersArray
Application("usersID")=usersID
End If
End If
End Sub
''***********************************************************
Sub Session_OnEnd
Dim usersArray, usersID, x
usersArray=Application("usersArray")
usersID=Application("usersID")
For x=0 To 99
If usersID(x)=Session.SessionID Then
usersID(x)=""
usersArray(x)=""
Application("usersArray")=usersArray
Application("usersID")=usersID
Exit For
End If
Next
End Sub
''************* CHECKUSERS.ASP: ******************************
Dim usersArray, x
usersArray=Application("usersArray")
Response.Write("USERS: <BR>")
For x=0 To 99
If usersArray(x)<>"" Then
Response.Write(x&"."&usersArray(x)&"; "&"<BR>")
Else
'do nothing
End If
Next
It does exactly what I want, But how do I add a user to it?
-
May 23rd, 2001, 01:50 PM
#19
Lively Member
Just so you know, www.addfreestats.com has a free service called InLive! that displays the active # of users on the site.
-
May 23rd, 2001, 05:57 PM
#20
Good Ol' Platypus
I know what the problem is !!
You could add to the # of online GUESTS when the session starts. Then, when they login, decrease that session variable, and increase the # of online users. It would also be easy to grab their ID and take the names from a DB.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 24th, 2001, 02:53 AM
#21
I havnt had much time to try at the moment, Im concentrating on the forums it self first, then I will add it in.
-
May 24th, 2001, 07:24 AM
#22
Good Ol' Platypus
Actually, they aren't session variables, they are application variables.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 24th, 2001, 08:21 AM
#23
Originally posted by Sastraxi
Actually, they aren't session variables, they are application variables.
Yea thats it 
Does the global.asa have to be in the wwwroot?
-
May 25th, 2001, 02:10 AM
#24
Global.asa Doesnt need to be in the wwwroot directory. It has be in your website root.
-
Jun 28th, 2001, 10:01 AM
#25
Ahhhh, bringing back a thread from the dead 
kayoca, wwwroot is what i was refering to as the web site root.
Ive just got some time to try and implement this, this is what I have
Global.asa
Application("users")(99) ' Im not sure if thats the way to put a application level array ??
adduser.asp?user=username used to add a user to the list
Dim i
For i = 0 to 99
If Application("users")(i) = "" AND Application("users")(i) = Null Then
Application("users")(i) = Request.QueryString("user")
Response.End
End If
Next
user.asp displays users
Dim i
For i = 0 to 99
If Application("users")(i) <> "" AND Application("users")(i) <> Null Then
Response.Write(i & ". " & Application("users")(i) & "<BR>")
End If
Next
When I run adduser.asp?user=simon I get this error...
Microsoft VBScript runtime error '800a000d'
Type mismatch: '[undefined]'
/simon/online/user.asp, line 5 (ive highlighted line 5 red)
Ideas?
~Simon
-
Jul 6th, 2001, 06:11 AM
#26
I had a talk to Sastraxi over MSN and sorted a few things with my code but I still have few problems 
Global.asa
Sub Application_OnStart
Application("users")(99)
End Sub
users.asp
<%
Dim i
For i = 0 to 99
If IsEmpty(Application("users")(i)) = False Then
Response.Write(i & "<BR>" & Application("users")(i) & "<BR>")
End If
Next
%>
When i run users.asp i get this error, line 6 is highlighted above in red
Microsoft VBScript runtime error '800a000d'
Type mismatch: '[undefined]'
/simon/online/read.asp, line 6
any ideas?
cheers
-
Jul 6th, 2001, 08:15 AM
#27
Its saying Application("users")(i) doesnt exist.
If you want to use arrays perhaps you can try setting a array variable in your Application.
-
Jul 6th, 2001, 08:31 AM
#28
Originally posted by kayoca
If you want to use arrays perhaps you can try setting a array variable in your Application.
???
The Application array does exsit as I am declaring it in the global.asa
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|