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

What is the difference between session object and application object?

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

P: 7
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: 37
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

P: 6
Application object

The Application object is used to store and access variables from any page, just like the Session object.
The difference is that ALL users share ONE Application object (with Sessions there is ONE Session object for EACH user).

Application object is used to store application specific data into server memory
Application["MyData"]="Gobal value"

Session object

ASP solves this problem by creating a unique cookie for each user.
The cookie is sent to the user's computer and it contains information that identifies the user.
This interface is called the Session object.
The Session object stores information about, or change settings for a user session.

Session object is used to store user specific data into server Memory.
Session["MyData"]="Store this data"
Feb 5 '20 #4

Post your reply

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