Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Lake Forest, CA
    Posts
    259
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Member Counter...

    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.

    Thanks!

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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.
    OracleGuy

  • #3
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    That's the way I will do mine aswell.

    I haven't started it, but I have learned that is a good way to do it.

    But I never really looked into it.

    Since I run my own server, is there away to use the global.asa file for this?

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Plano, Texas
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Some global.asa examples of listing members:

    http://www.aspalliance.com/AlexCampb...15&Version=ASP

    http://www.aspalliance.com/AlexCampb...PrintView=True



    4Guys With an example of just the number of visitors on line:

    http://www.4guysfromrolla.com/webtech/061399-2.shtml

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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. ;)

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Lake Forest, CA
    Posts
    259
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oracleguy, how do i make the field determine if the users session is "True" or "False"?

    Thanks!

  • #7
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    You'd write to the database when the logged in.


    Then in your globa.asa(x) you'd have in the Session_OnEnd have it write to the database again setting it back to false.
    OracleGuy

  • #8
    Regular Coder
    Join Date
    Nov 2002
    Location
    Loughborough (UK)
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    session end

    Hi Guys,

    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

  • #9
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: session end

    Originally posted by christrinder
    Hi Guys,

    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.

  • #10
    Regular Coder
    Join Date
    Nov 2002
    Location
    Loughborough (UK)
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    Hi,

    Thanks. I'm using Brinkster for my own site, although I am also developing one for use on a network, through window's PWS thing. Any ideas?

    Cheers,

    Chris

  • #11
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    If you have a free account from brinkster then you are unable to use the global.asa

    But on you PWS you can use a global.asa file and you can add all this stuff inside it.

    I guess you will just need to wait untilt he PWS is ready and then you can use it.

  • #12
    Regular Coder
    Join Date
    Nov 2002
    Location
    Loughborough (UK)
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Non global ASA

    Thanks for that.

    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?

    Thanks,

    Chris

  • #13
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    In the global.asa file you can add:

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •