Monday, January 31, 2011

Session Vs Application variable

Session Vs Application variable

Application Variables:
Application variables are the variables which remain common for the whole application for all the users… Their value can be used across the whole application by any user… And they die only when the application stops or probably when they are killed forcibly… The ideal example for these kind of variables are site counter… We can find out how many people accessed a particular site since the time it went live via application variables and incrementing the same on ever session start.

Session Variables:
Session variables are variables which remain common for the whole application but for one particular user. They also can be used across the whole application but each user will have a copy… But they die when a particular user session ends or probably when they are killed forcibly… The ideal example for this kind of variable are user id… You might want to show "Welcome Meetu Choudhary " on every page of your site till Meetu Choudhary logs off… So in session start you set a variable to "Welcome Meetu Choudhary" and kill it on end of session…

All these events session start, session end, application start, application end are found in global.asax and that’s the reason global.asax is one for the whole ASP.Net application…

1 comment: