Total number of users are accessing the ASP application?

text zoom

The Application object is used,as it is global to all users. Remember to lock and unlock the Application object.



 











<%


session("account") = Request.Form("account")


%>


 




 






The session onstart and onend events are the two events used to add and remove the user from the total user count.



 










<%


Sub Session_OnStart()

   '**Put your code here **

    Application.Lock


    Application("totalusers") = Application("totalusers") + 1


   Application.Unlock

End Sub



Sub Session_OnEnd()

    '**Put your code here **


    Application.Lock


    Application("totalusers") = Application("totalusers") - 1


   Application.Unlock



End Sub


 


%>


 




 


To print the number of users,just print to the page like so,










<%


Response.Write "The number of users currently using the site are : " &  Application("totalusers") 


%>


 

 






                    

Copyright © 2013 VisualBuilder. All rights reserved