View Single Post
  #4 (permalink)  
Old December 7th, 2009, 02:48 AM
irProject irProject is offline
Friend of Wrox
 
Join Date: Nov 2009
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Default

session variables are available in all pages
there is two functions declared in global.asax file that wire up when needed
Code:
void Session_OnStart(...)
{
 // when session starts. code goes here ... eg
 int counter = int.Parse(Session["onlineUsers"].ToString());
 counter++;
 Session["onlineUsers"] = counter;
}

void Session_OnEnd(...)
{
 // when a session ends
 int counter = int.Parse(Session["onlineUsers"].ToString());
 counter--;
 Session["onlineUsers"] = counter;
}