Hi, i have a member login system, and what i want to do is, on the main page, tell anyone who comes to my website, how many members are logged in, and list there usernames.
I'm working on something similar at the moment. What I figured out is to add an additional field to the table that I used to store usernames and passwords. That when they logged in was changed to 'true' then when they logged off or their session timed out it changed it to 'false'.
So then I made a SSI that ran the SQL query of
strQuery="SELECT * from 'users' where 'Status'='True'"
Then it just counts and lists the usernames that are logged in.
I've used the global.asa to do this, it should work fine for you. There is even an example at http://www.w3schools.com/asp if you look at the "global.asa" link.
__________________
Former ASP Forum Moderator - I'm back!
If you can teach yourself how to learn, you can learn anything. ;)
Just been reading through your posts, your original query is something I wanted to do. I'm not at all familiar with whatever asa global is, so is there another way I can return to the logged-in field to false when their session expires??
Just been reading through your posts, your original query is something I wanted to do. I'm not at all familiar with whatever asa global is, so is there another way I can return to the logged-in field to false when their session expires??
Thanks,
Chris
Well first off, Chris. Do you run your own server, or are you being hosted online? Like @ Brinkster.com?
If you run your own server, it would be good to use Global.asa, and the few links above talk about usiong Global.asa and if it's right for you.
I think Session Time Out is not part of global.asa as much as it just deals with an internal Timer. I think a session lasts about 5-10 minutes, but I am not sure.
Your host might allow you to use a global.asa somehow.
So is there another way I can return the 'loggedin' field to false when the session expires? I'm not particularly sure of the command I should write to make this happen? Any suggestions, or handy example codes?
Sub Session_OnEnd
Set oConn = Server.CreateObject("ADODB.Connection")
StrConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db.mdb") & ";"
oConn.open StrConn
sSQL = "UPDATE Members SET Loggedin=False WHERE (ID=" & Session("ID") & ")"
Set oRS = oConn.Execute(sSQL)
End Sub
Session("ID") = The ID number of the person in the session (A login script where you add the info to the cookies is a good place to make the Session("ID") tag.
Though, for some odd reason I am having troble with this script. I don't know what's wrong with it, but I am starting a new thread seeing if anyone can help me.