468,117 Members | 1,964 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,117 developers. It's quick & easy.

What is the difference between session object and application object?

What is the difference between session object and application object?
May 6 '19 #1
3 3334
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
AjayGohil
84 64KB
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
Sherin
77 64KB
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.

Similar topics

6 posts views Thread by lawrence | last post: by
9 posts views Thread by gulu man | last post: by
100 posts views Thread by E. Robert Tisdale | last post: by
3 posts views Thread by Berkdan | last post: by
2 posts views Thread by Steve Peterson | last post: by
13 posts views Thread by | last post: by
5 posts views Thread by =?Utf-8?B?UGhpbCBKb2huc29u?= | last post: by
10 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.