Learn about ASP Session Objects (11.1 ASP):

ASP 11.1

The object which stores information or change settings of a user session is known as Session Object.

A session is the duration in which user opens an application, performs some changes in it and then closes it. During this session your computer knows everything about the opening of an application, changes you made in it and the closing of an application. But the server does not know anything about the session of an application because HTTP does not keep the information of this sort.

ASP solves this problem by using the interface of Session object. ASP basically creates a special cookie and sends it to the user computer to identify the user. This is known as Session Object.

Session Objects comprises of different variables which store information about the single user. But this information is available to every page of an application. Few common type of information stored in session objects are name, id and the user preferences. But the server destroys the session object after creating a new session object.

You must be wondering when a session starts? The session starts when

  1. any user requests an ASP file and there is a Session_On Procedure in the Global_asa file.
  2. There is any value stored in the session variable.
  3. any user requests an ASP file and there is a <Object>Tag in the Global_asa file to instantiate the session object.

The next question which comes in mind after this is When a session ends? So, the answer is that if the user is not using an application for a default period of time than the session will expire. By default this time is 20 minutes. This time can be changed by using the “Timeout” Property of the session. Following is an example where you can change the default time to 40 minutes:


<%

Session.Timeout=40

%>

But if ending the session immediately is needed then you can use “Abandon“ property of session. Following is the property that shows the syntax to end the session immediately:

<%

Session. Abandon

%>

Now the issue is when to end the session. For example you are using an application for past 20 minutes. Then you stop using it for like an hour. In the meantime this application is using loads of resources on the server for no use. So to reduce the resources, if the server shuts the session like after the 5 minutes( you have not been using the application). Then you would have to start again if by any chance you come back sooner than an hour.  Therefore to find the right time to end the session is quite difficult and unpredictable. So, to avoid this issue we can store few variables in the session object.

The next post will explain about Storing, Removing and Retrieval of session variables. Also it will explain the procedure to loop the content collection and the Static Object collection.

For more visit next posts in this category.To go back to Contents of this tutorial: ASP Active Server Side Scripting Contents

email

One Response to Learn about ASP Session Objects (11.1 ASP):

  1. I think this is among the so much important info for me. And i am glad studying your article. But wanna commentary on some common issues, The website style is great, the articles is truly nice : D. Good task, cheers

Leave a Reply