NOTE: this example is just for a novice programmer (NOT for ASP expert programers)
1) Go to Global.asax.cs file and identify the application startup function and then add a Session counter variable. Like this...
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application.Add("NOF_USER_SESSION", 0);
2) Then in the same GLobal.asax.cs file keep adding/reducing the user counts in Session-Startup and Session-Endup function respectively... like this...
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Application["NOF_USER_SESSION"] = (int)Application["NOF_USER_SESSION"] + 1;
..
..
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
Application["NOF_USER_SESSION"] = (int)Application["NOF_USER_SESSION"] - 1;
..
..
3) Then use this Application level variable (int)Application["NOF_USER_SESSION"]
wherever you can inside your program.