•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 332,778 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,830 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
This is a neat little script that will tell you how many active users
you have on your site. You do need a webhost that supports the
global.asa file! Most free hosts dont.
Code From: http://www.iportalx.net
you have on your site. You do need a webhost that supports the
global.asa file! Most free hosts dont.
Code From: http://www.iportalx.net
Last edited : Jan 2nd, 2007.
First lets create the global.asa file that counts the active users. Again, your host must support global.asa files or this will not work! [code] <script language="vbscript" runat="server"> Sub Application_OnStart 'Set the active users to zero Application("ActiveUsers") = 0 End Sub Sub Application_OnEnd 'no code is needed here End Sub Sub Session_OnStart Session.Timeout = 5 Session("Start") = Now Application.Lock 'Add one to the active users when the person first visits Application("ActiveUsers") = Application("ActiveUsers") + 1 'this adds 1 to the number of active users when a new user hits Application.unlock End Sub Sub Session_OnEnd Application.Lock 'Subtract one after the user leaves your website Application("ActiveUsers") = Application("ActiveUsers") - 1 'this subtracts 1 from the number of active users when a new user leaves Application.unlock End Sub </SCRIPT> [/code] Now that the global.asa file is created you can include the following any where on your ASP pages. [code] You are one of <b><% = Application("ActiveUsers") %></b> current users [/code] Note: You do not need to include the global.asa file! Now upload the global.asa file to the ROOT directory of your website (that would be the very first directory that your website looks in when you visit you websites URL).
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)