I create a table in database add users to database and when users login to website i add their code to Session now how can i get number of users that online and get their code ?
i use below code but doesn’t work
MembershipUserCollection users= Membership.GetAllUsers();
int a=Membership.GetNumberOfUsersOnline();
A Solution can be to create a New Application Variable. You can make a collection variable and add users when they log into your application (with
Session_start()method) and remove them when session timed out (Session_end()). These two methods are in the Global.asax fileThe point is the delay. Users will be removed at session_end so it will be a delay between “browser closure” and session time out. This delay will be equal to the session life time for your application.