By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,684 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,684 IT Pros & Developers. It's quick & easy.

What is the difference between session object and application object?

P: 21
What is the difference between session object and application object?
May 6 '19 #1
Share this Question
Share on Google+
2 Replies


P: 6
Session variables are used to store user specific information where as in application variables we can't store user specific information.

Default lifetime of the session variable is20 mins and based on the requirement we can change it.



Application variables are accessible till the application ends.

sessions allows information to be stored in one page and accessed in another,and it supports any type of object,including your own custom data types.



Application state allows you to store global objects that can be accessed by any client.

The coomon thing b/w session and application is both support the same type of objects,retain information on the server, and uses the same dictionary -based syntax.
May 6 '19 #2

P: 16
Session object
Session object is used to store state specific information per client basis. It is specific to particular user. Session data persists for the duration of user session you can store session's data on web server in different ways. Session state can be configured using the <session State> section in the application's web.config file.
Application object
Application object is used to store data which is visible across entire application and shared across multiple user sessions. Data which needs to be persisted for entire life of application should be stored in application object.
In classic ASP, application object is used to store connection strings. It's a great place to store data which changes infrequently. We should write to application variable only in application_Onstart event (global.asax) or application.lock event to avoid data conflicts. Below code sample gives idea
May 29 '19 #3

Post your reply

Sign in to post your reply or Sign up for a free account.