Matthew McLeod
Matthew McLeod

Reputation: 27

Session state vs Application State

I'm currently researching .Net through their HTML5 MTA course. My book has this explanation of Session vs Application state:

State management is the process of maintaining Web page information during multiple requests for the same or different Web page. When a user first requests access to an application, the session state is created. The state ends when the user closes the session.

This is confusing me because they seem to be saying the same thing.
A requests to an application = session state
A request for a webpage = Application state
Are webpages not applications?

It then describes Persistent state information as:

Persistent state information is data that an application needs after the session ends. Many Web applications need to store data (make it persistent) so that users can pick up where they left off when they return to the site.

'data that an application needs after the session ends' - you just told me session states come before application states?
im so confused can someone help explain these 2 concepts for me?

Upvotes: 2

Views: 8151

Answers (3)

Geena
Geena

Reputation: 11

Application State is data that is particular to the application. It is stored in the server, so can be easily accessed and helps in fast retrieval. This is used when you have a variable that needs to be globally accessed and exist for the entire lifetime of the application.

Session State is used to maintain data specific to a user.It is stored in the server or database.This is a single user- global variable.

Upvotes: 1

Björn Tantau
Björn Tantau

Reputation: 1614

This is actually not limited to .net.

  1. Application state is what is in RAM while the application is running. For some server side languages the application runs only for one request, for others it runs until the corresponding server process is stopeed. In the latter case application state is shared for many users.
  2. Session state is what is tied to a particular user. In most cases it is stored in the filesystem or a database and retrieved through a key stored in a session-cookie. With this key the application can retrieve session data and act on it. When the user closes the browser the session-cookie is deleted and thus the session data cannot be retrieved anymore. We call that a session end. The actual data will have to be purged periodically through other means, like a cron script.
  3. Persistent data is data that was stored in a database or filesystem using a more or less known key. Like a username or page id.

Upvotes: 5

Hans Kesting
Hans Kesting

Reputation: 39329

"Application state" = the state of the application, which is the same for all users.

"Session State" = state specific to this particular user session. Each user has separate session state.

Upvotes: 5

Related Questions