You are here Articles List / ASP Overview Section 5

ASP Overview - Session Object

     Introduction
     Response
     Request
     Application
     Session
     Server

Session Object
The Session Object is used to maintain state across web applications. What this means is that regular html pages are requested by the browser and then sent. The connection between the server and the browser is connected and disconnected each time a request is made. To combat this ASP has the Session Object. This object allows you to set Session variables that can be used from page to page within your application.
*Remember, there is one Application Object for all users, but each user has their own Session Object that is unique to them.

An example use of the Session Object is to set a Session variable equal to whether or not the current user is logged in. To do this we would first check the Session variable to see if the requesting user is logged in. If they are logged in we would send them to a specific page, if not then we would send them to the login page. At the login page, the user would type in their name and password, the script would check it for accuracy and then if it was correct set a Session variable stating that they have successfully logged in. The setting of the Session variable is show in the example below:

Session("loggedin") = "yes"

In the above code we set the "loggedin" Session variable equal to yes. This way if the user requests another page that requires them to be logged in, we simply check the Session variable to see if it equals "yes".

<< Prev Section - Application Object  ||  Next Section - Server Object >>