A
Andrew Banks
I'm wanting to track the number of users using an application.
I'm using App variables and incrementing an int value by 1 everytime a new
session is started. I'm having a problem decrementing this int once they
close their browser.
I assumed that putting some code in Session_End in Global.asax to do this
would work but it seems it doesn't. Is a session not ended once a user
closes their browser or does the session not end until the timeout period as
set in web.config has passed?
Any help is most appreciated
Sample code is below;
// Extract from Global.asax
protected void Session_Start(Object sender, EventArgs e)
{
Application.Lock();
Application["TotalPlayers"] = (int)Application["TotalPlayers"] + 1;
Application.UnLock();
}
protected void Session_End(Object sender, EventArgs e)
{
Application.Lock();
Application["TotalPlayers"] = (int)Application["TotalPlayers"] - 1;
Application.UnLock();
}
// Extract from web.config
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="5"
/>
I'm using App variables and incrementing an int value by 1 everytime a new
session is started. I'm having a problem decrementing this int once they
close their browser.
I assumed that putting some code in Session_End in Global.asax to do this
would work but it seems it doesn't. Is a session not ended once a user
closes their browser or does the session not end until the timeout period as
set in web.config has passed?
Any help is most appreciated
Sample code is below;
// Extract from Global.asax
protected void Session_Start(Object sender, EventArgs e)
{
Application.Lock();
Application["TotalPlayers"] = (int)Application["TotalPlayers"] + 1;
Application.UnLock();
}
protected void Session_End(Object sender, EventArgs e)
{
Application.Lock();
Application["TotalPlayers"] = (int)Application["TotalPlayers"] - 1;
Application.UnLock();
}
// Extract from web.config
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="5"
/>