Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Who’s Online Help
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Who’s Online Help

 Post Reply Post Reply
Author
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Topic: Who’s Online Help
    Posted: 31 December 2003 at 4:26pm

I am trying to add a feature to my script that allows the admin to see who is online but I am having a problem.  All I ever see is Guest-XXXXX instead of the actual username.  Can someone help me out. 

Thanks

 Here is the code I am using.

Global.asa

<Object Runat="Server" Scope="application" ID="dOnlineUsers" ProgID="Scripting.Dictionary"></Object>

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

sub Application_OnStart
    application("ServerStart") = now
end sub

function Decrypt(sText)
    'Replace with your own decrypt ;)
    Decrypt = sText
end function   

function adZero(sText)
    'Adds zeros to the beginning
    if isNull(sText) then exit function
    adZero = string(5 - len(sText), "0") & sText
end function

Sub Session_OnStart

    'Session_OnStart is automatically called by the ASP Interpreter
    'when a new session starts. (Probably a new visitor)

    'TimeOut value determines the period in minutes when
    'the session is assumed to be abandoned

    Session.TimeOut = 10

    'Get the current active users list
    sActiveUsersList = application("ActiveUsersList")
   
    'Get the new user name from the cookie
    sNewUserName = Decrypt(request.cookies("userName"))
   
    'If the visitor doesn't have a registered username, assign Guest(n) label
    if sNewUserName = "" then sNewUserName = "Guest-" & AdZero(CInt(application("Visitors")))
   
    'Initial action time
    sLastActionTime = Time
   
    'User info consists of user name, last action time, and the page viewed
    sUserInfo = sNewUserName & "<|>" & sLastActionTime & "<|>" & sLastPageViewed

    'Add this user to our collection with SessionID being the key
    '(See the top of this file to see how dOnlineUsers object is initiated)
    dOnlineUsers.Add Session.SessionID, sUserInfo
   
    'Lock the application variable and update the contents
    application.lock
    'The number of active users
    application("ActiveUsers") = application("ActiveUsers") + 1
    'The number of visitors since last application reset
    application("Visitors") = application("Visitors") + 1
   
    'If the date is different than the previously stored date,
    'it means we passed midnight, so reset our "today" counters
    if application("TodaysDate") <> Date() then
        application("PageViewsToday") = 0
        application("VisitorsToday") = 0
    end if
    application("VisitorsToday") = application("VisitorsToday") + 1
    'Store the date
    application("TodaysDate") = Date()
    'Unlock and go
    application.unlock
   
End Sub

Sub Session_OnEnd
    'Session_OnEnd is automatically called by the ASP Interpreter
    'when the specified TimeOut period has passed after user's last action

    on error resume next

    'Remove this session from our collection
    dOnlineUsers.Remove Session.SessionID
   
    'And update the application variables
    application.lock
    application("ActiveUsers") = application("ActiveUsers") - 1
    application.unlock

End Sub
</SCRIPT>

 

The header part of all my files

<%

function Decrypt(sText)
    'Replace with your own decrypt ;)
    Decrypt = sText
end function   


    application.lock
    application("PageViews") = application("PageViews") + 1
    if application("TodaysDate") <> Date() then
        application("PageViewsToday") = 0
        application("VisitorsToday") = 0
    end if
    application("PageViewsToday") = application("PageViewsToday") + 1
    application("TodaysDate") = Date()
    application.unlock
   
    if session("userName") = "" then
        session("userName") = Decrypt(request.cookies("userName"))
        'session("FullName") = Decrypt(request.cookies("FullName"))
    end if

    session("PageViewed2") = session("PageViewed1")
    session("PageViewed1") = session("PageViewed0")
    session("PageViewed0") = request.ServerVariables("script_name")
   
    sUserInfo = dOnlineUsers.Item(Session.SessionID)
    aUserInfo = split(sUserInfo, "<|>")
    aUserInfo(1) = Time()
    aUserInfo(2) = request.ServerVariables("script_name")
    sUserInfo = aUserInfo(0) & "<|>" & aUserInfo(1) & "<|>" & aUserInfo(2)
    dOnlineUsers.Item(Session.SessionID) = sUserInfo
   
   
%>

 

And the page that views the people online

    on error resume next
    response.write "<table cellpadding=""2"" cellspacing=""1"" border=""0"" width=""100%"">"        ; ;
    response.write "<tr><td></td><td><strong>Who& amp; lt;/strong></td><td><strong>When</st rong></td><td><strong>Where</strong& amp; gt;</td></tr>"
    aSessions = dOnlineUsers.Keys
    for iUser = 0 to dOnlineUsers.Count - 1
        sKey = aSessions(iUser)
        sUserInfo = dOnlineUsers.Item(sKey)
        aUserInfo = split(sUserInfo, "<|>")
       
        sUserName = aUserInfo(0)
        sLastActionTime = aUserInfo(1)
        sLastPageViewed = aUserInfo(2)
       
        if sUserInfo <> "" then
        iUsrCount = iUsrCount + 1
        response.write "<tr><td align=""right"">" & iUsrCount & ".</td><td> " & sUserName & "</td><td>" & sLastActionTime & "</td>"
        response.write "<td>" & sLastPageViewed & "</td></tr>"
        end if
        <

Back to Top
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Posted: 01 January 2004 at 6:17pm
Anybody have any thoughts.  Because if I do a request.write on the cookie I get the correct username.  That is why I am stuck.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.