SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    May 2004
    Location
    uk
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how do i - online users script?

    I have just finished making the basic login/register bit to my new site , i want to make a online users script to show members online and visitors online (how many)

    How would this be done as global.asa cant hold asp coding so it can only cold visitors not members

    Cheers people

  2. #2
    SitePoint Zealot howardroark`'s Avatar
    Join Date
    Feb 2005
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there are many ready made scripts like this at aspin.com and hotscripts.com, check them out

  3. #3
    SitePoint Member
    Join Date
    May 2004
    Location
    uk
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would like to find out howto do it tho for future projects , these scripts are usually got lots of code around them or just plain visitors scripts

  4. #4
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Easiest way of doing it:

    This goes in your global.asa file in your root directory:
    Code:
    <SCRIPT LANGUAGE="VBScript" RUNAT="Server">
    Sub Session_onStart()
    Application("NumOfVisitors") = Application("NumOfVisitors") + 1
    End Sub
    Sub Session_onEnd()
    Application("NumOfVisitors") = Application("NumOfVisitors") - 1
    End Sub
    </SCRIPT>
    and this is how you display it on a page:
    Code:
    <%
    response.write Application("NumOfVisitors")
    %>

  5. #5
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How Could U Achieve This Without Global.asa

  6. #6
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You can't, as you need the Session_OnEnd to remove the current session from the list. It can be done without, but you cannot guarantee that the user will log out manually.

    I prefer to create a list of sessionID's when someone enters the site
    Code:
    Application.Lock
    Application("all_sessions")=Application("all_sessions") & Session.SessionID & "|"
    Application.UnLock
    then you can add the users name to their sessionID when they have logged in
    Code:
    application.lock
    Application("all_sessions")=replace(Application("all_sessions"),session.sessionid,session.sessionid & ":" & user_name)
    application.unlock
    and remove it with Session_OnEnd in global.asa with
    Code:
    Sub Session_OnEnd
    dim objRegExp
    SET objRegExp = NEW RegExp
    objRegExp.pattern = Session.SessionID & "(:\w+)?\|"
    objRegExp.global = true
    Application.Lock
    Application("all_sessions") = objRegExp.replace(Application("all_sessions"),"") 
    Application.UnLock
    SET objRegExp = NOTHING
    End Sub
    I don't know if there's a more accurate way
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  7. #7
    SitePoint Member
    Join Date
    May 2004
    Location
    uk
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    These are for just visitors tho , i would like members the visitors like vbulletin if u get me

  8. #8
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    mxadam, the script above is for both visitors and members.
    the visitors count is got from using
    Code:
    ubound(split(application("all_sessions"),"|"))
    the members count is
    Code:
    ubound(split(application("all_sessions"),":"))
    and the members online is got by looping through all_sessions and looking for names.
    Code:
    allSessions=split(application("all_sessions"),"|")
    session_count=ubound(allSessions)
    for i=0 to session_count
    if instr(allSessions[i],":")>0 then
    online_member=split(allSessions[i],":")(1)
    response write(online_member & " is online")
    end if
    next
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


Bookmarks

Posting Permissions

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