Avatar billede guzzie Nybegynder
04. april 2001 - 11:11 Der er 18 kommentarer og
1 løsning

list of online users

Hey There

I am trying to get my server your show a list of all my online users that have logged onto my site
I have a username and password login that creates a session called \"name\"
I am trying to have a list on my page of all the current session names
I found this artical
http://www.activeserverpages.dk/julekalender/julegaver/whoson.asp
but cant seem to get the damn thing to work (Probably my bad danish :)
I found a few other questions here on eksperten but coundn\'t seem to find the right answer :(
Any Ideas
Guzzie
Avatar billede dudal Nybegynder
04. april 2001 - 11:13 #1
Do you get any exact errors when trying to use script from the article above ?
Avatar billede guzzie Nybegynder
04. april 2001 - 11:30 #2
Hey There
I dont get any error but then again nothing gets shown :(
My global.asa file looks like this
<script language=VBScript runat=Server>

Sub application_OnStart
Application.Lock
Application(\"OnlineUsers\") = \",\"
Application.UnLock



End Sub



Sub Session_OnEnd

Application.Lock
Application(\"OnlineUsers\") = Replace(Application(\"OnlineUsers\"), Session(\"name\") & \",\")
Application.UnLock


End Sub

Sub application_OnEnd
End Sub

</script>


the page I an testing on looks like this
<!--#include file=is_this_person_logged_in_checker.inc-->

<%
\' --- procedure til at tilføje en online bruger ---
Sub AddOnlineUser()
    Application.Lock
    Application(\"OnlineUsers\") = Application(\"Onlineusers\") & Session(\"name\") & \",\"
    Application.UnLock
End Sub

\' --- funktion som retunerer antallet af online brugere ---
Function CountOnLineUsers()
    Dim arrUsers
    \' --- lav et array med online brugere ---
    arrUsers = Split(Application(\"Onlineusers\"), \",\")
    \' --- antallet af online brugere er altid størrelsen på arrayet -1 ---
    CountOnLineUsers = UBound(arrUsers) - 1
End Function

\' --- procedure til at udskrive online brugere ---
Sub WriteOnLineUsers()
    Dim arrUsers
    Dim n
    \' --- lav et array med online brugere ---
    arrUsers = Split(Application(\"Onlineusers\"), \",\")
    \' --- udskriv liste ---
    For n = 1 To UBound(arrUsers) -1
        Response.Write(arrUser(n) & \"<br>\")
    Next
End Sub
%>

<html>
<head>
<title><%=session(\"name\")%></title>
</head>
<link rel=\"stylesheet\" type=\"text/css\" href=\"styles_old.css\">
<body background=\"../grafik/bg.jpg\">
<table>
<tr><td>Welcome <%=session(\"name\")%> the following people are online</td></tr>

<tr><td><%
Response.Write WriteOnlineUsers()
%></td></tr>
</table>
</html>

Guzzie
Avatar billede dudal Nybegynder
04. april 2001 - 11:42 #3
In the file:
is_this_person_logged_in_checker.inc

Are you using

Sub AddOnlineUser()
    Application.Lock
    Application(\"OnlineUsers\") = Application(\"Onlineusers\") & Session(\"name\") & \",\"
    Application.UnLock
End Sub

To add the user to your list?

AddOnlineUser(UserName)

/Jesper
Avatar billede dudal Nybegynder
04. april 2001 - 11:43 #4
Sorry: AddOnlineUser(UserName) --> AddOnlineUser()
Avatar billede guzzie Nybegynder
04. april 2001 - 11:46 #5
hey there

the only contents of that file arre this
<%
if session(\"login\") = false then
response.redirect (\"admin_login.asp\")
end if
%>

Guzzie
Avatar billede guzzie Nybegynder
04. april 2001 - 11:47 #6
its just a normal include file at the top of the page then the rest of the script ?
Guzzie
Avatar billede dudal Nybegynder
04. april 2001 - 11:49 #7
Ok... On admin_login, where the user logs in and Session(\"login\") i set, you have to call the sub:

Sub AddOnlineUser()
    Application.Lock
    Application(\"OnlineUsers\") = Application(\"Onlineusers\") & Session(\"name\") & \",\"
    Application.UnLock
End Sub

Remember that you have to have the Session(\"name\") variable set for it to work.

Then it should work. :-)

/Jesper
Avatar billede guzzie Nybegynder
04. april 2001 - 12:02 #8
Hey Jesper

The page where I login and the session name gets created looks like this
<%
set Con = server.CreateObject(\"ADODB.connection\")
Con.open \"Driver={Microsoft Access Driver (*.mdb)};dbq=\" & Server.MapPath(\"admin_writers.mdb\")

name = request.form(\"login\")
password = request.form(\"password\")

rsSQL = \"SELECT * FROM writers WHERE name = \'\" & name & \"\' AND password = \'\" & password & \"\'\"
set rs = Con.execute(rsSQL)

if rs.eof then
session(\"login\") = \"\"
response.redirect (\"admin_login.asp?error=error\")
else
session(\"login\") = true
session(\"name\") = name
session(\"email\") = RS(\"email\")
session(\"admin_level\") = RS(\"admin_level\")
response.redirect (\"default.asp\")
end if
%>

I dont have any sub :( ??
guzzie
Avatar billede dudal Nybegynder
04. april 2001 - 12:04 #9
<%
set Con = server.CreateObject(\"ADODB.connection\")
Con.open \"Driver={Microsoft Access Driver (*.mdb)};dbq=\" & Server.MapPath(\"admin_writers.mdb\")

Sub AddOnlineUser()
    Application.Lock
    Application(\"OnlineUsers\") = Application(\"Onlineusers\") & Session(\"name\") & \",\"
    Application.UnLock
End Sub

name = request.form(\"login\")
password = request.form(\"password\")

rsSQL = \"SELECT * FROM writers WHERE name = \'\" & name & \"\' AND password = \'\" & password & \"\'\"
set rs = Con.execute(rsSQL)

if rs.eof then
session(\"login\") = \"\"
response.redirect (\"admin_login.asp?error=error\")
else
session(\"login\") = true
session(\"name\") = name
session(\"email\") = RS(\"email\")
session(\"admin_level\") = RS(\"admin_level\")
response.redirect (\"default.asp\")
Call AddOnlineUser()
end if
%>

That should do the trick...

/jesper
Avatar billede guzzie Nybegynder
04. april 2001 - 12:10 #10
Hmmm its still not working
I have a couple of asp pages
the global.asa
login page - this only contains a form
login_check - thats the one that creates the session
then the test page - the test page code looks like this
<!--#include file=is_this_person_logged_in_checker.inc-->

<%
\' --- procedure til at tilføje en online bruger ---
Sub AddOnlineUser()
    Application.Lock
    Application(\"OnlineUsers\") = Application(\"Onlineusers\") & Session(\"name\") & \",\"
    Application.UnLock
End Sub

\' --- funktion som retunerer antallet af online brugere ---
Function CountOnLineUsers()
    Dim arrUsers
    \' --- lav et array med online brugere ---
    arrUsers = Split(Application(\"Onlineusers\"), \",\")
    \' --- antallet af online brugere er altid størrelsen på arrayet -1 ---
    CountOnLineUsers = UBound(arrUsers) - 1
End Function

\' --- procedure til at udskrive online brugere ---
Sub WriteOnLineUsers()
    Dim arrUsers
    Dim n
    \' --- lav et array med online brugere ---
    arrUsers = Split(Application(\"Onlineusers\"), \",\")
    \' --- udskriv liste ---
    For n = 1 To UBound(arrUsers) -1
        Response.Write(arrUser(n) & \"<br>\")
    Next
End Sub
%>

<html>
<head>
<title><%=session(\"name\")%></title>
</head>
<link rel=\"stylesheet\" type=\"text/css\" href=\"styles_old.css\">
<body background=\"../grafik/bg.jpg\">
<table>
<tr><td>Welcome <%=session(\"name\")%> the following people are online</td></tr>

<tr><td><%
Response.Write WriteOnlineUsers()
%></td></tr>
</table>
</html>

Me up the points to 60 :)
Guzzie
Avatar billede dudal Nybegynder
04. april 2001 - 12:25 #11
Just Put this code into login_check.asp

<%
set Con = server.CreateObject(\"ADODB.connection\")
Con.open \"Driver={Microsoft Access Driver (*.mdb)};dbq=\" & Server.MapPath(\"admin_writers.mdb\")

Sub AddOnlineUser()
    Application.Lock
    Application(\"OnlineUsers\") = Application(\"Onlineusers\") & Session(\"name\") & \",\"
    Application.UnLock
End Sub

name = request.form(\"login\")
password = request.form(\"password\")

rsSQL = \"SELECT * FROM writers WHERE name = \'\" & name & \"\' AND password = \'\" & password & \"\'\"
set rs = Con.execute(rsSQL)

if rs.eof then
session(\"login\") = \"\"
response.redirect (\"admin_login.asp?error=error\")
else
session(\"login\") = true
session(\"name\") = name
session(\"email\") = RS(\"email\")
session(\"admin_level\") = RS(\"admin_level\")
response.redirect (\"default.asp\")
Call AddOnlineUser()
end if
%>

I added the AddOnlineUser Sub. That\'s it. Then after you login you should be able to see your username on the page that shows onlineusers.

/Jesper
Avatar billede dudal Nybegynder
04. april 2001 - 12:26 #12
Oh, change

<tr><td><%
Response.Write WriteOnlineUsers()
%></td></tr>


into:

<tr><td><% WriteOnlineUsers() %></td></tr>
Avatar billede guzzie Nybegynder
04. april 2001 - 12:32 #13
Hmmm damn :(
its still not working :(

is not just easier to create a db where the session name gets inserted and then deleted og a certain lenght of time ???

Guzzie
Avatar billede guzzie Nybegynder
04. april 2001 - 12:33 #14
og = after :)
Avatar billede dudal Nybegynder
04. april 2001 - 12:48 #15
Application(\"OnlineUsers\") = Replace(Application(\"OnlineUsers\"), Session(\"name\") & \",\",\"\")

Should be in global.asa insted of

Application(\"OnlineUsers\") = Replace(Application(\"OnlineUsers\"), Session(\"name\") & \",\")
Avatar billede guzzie Nybegynder
04. april 2001 - 12:52 #16
Hey There

Application(\"OnlineUsers\") = Replace(Application(\"OnlineUsers\"), Session(\"name\") & \",\")
is already in my global.asa

hmmm I am totally lost now :(
Guzzie
Avatar billede dudal Nybegynder
04. april 2001 - 12:56 #17
My first line is different.

Session(\"name\") & \",\",\"\")  insted of Session(\"name\") & \",\")
Avatar billede guzzie Nybegynder
04. april 2001 - 13:12 #18
hmmm still nothing ?
Guzzie
Avatar billede guzzie Nybegynder
04. april 2001 - 16:42 #19
Well anyway Thanks for trying dudal
I will close the question now and try another day
thanks again
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester

IT-JOB

Capgemini Danmark A/S

AI/Data Engineer

Scan Global Logistics

PMO Project Manager

Politiets Efterretningstjeneste

DevOps engineer til dataanalyse i PET

Jyske Bank

AI-udvikler