Page 230 - DCAP408_WEB_PROGRAMMING
P. 230
Web Programming
Notes Self Assessment
Fill in the blanks:
5. ………………….. applies HTML encoding to a specified string.
6. ………………….. Sets or returns the maximum number of seconds a script can run before
it is terminated.
7. ………………….. returns an ASPError object that describes the error condition that occurred.
9.3 ASP Session Object
The Session Object is used to store information about, or change settings for a user session.
Variables stored in the Session object hold information about one single user, and are available
to all pages in one application.
When you are working with an application, you open it, do some changes and then you close it.
This is much like a Session. The computer knows who you are. It knows when you start the
application and when you end. But on the internet there is one problem: the web server does not
know who you are and what you do because the HTTP address doesn’t maintain state.
ASP solves this problem by creating a unique cookie for each user. The cookie is sent to the client
and it contains information that identifies the user. This interface is called the Session object.
The Session object is used to store information about, or change settings for a user session.
Variables stored in the Session object hold information about one single user, and are available
to all pages in one application. Common information stored in session variables are name, id,
and preferences. The server creates a new Session object for each new user, and destroys the
Session object when the session expires.
Task Analyze the working of the session object.
When does a Session Start?
A session starts when:
A new user requests an ASP file, and the Global.as a file includes a Session_OnStart procedure
A value is stored in a Session variable
A user requests an ASP file, and the Global.asa file uses the <object> tag to instantiate an
object with session scope.
When does a Session End?
A session ends if a user has not requested or refreshed a page in the application for a specified
period. By default, this is 20 minutes.
If you want to set a timeout interval that is shorter or longer than the default, you can set the
Timeout property.
The example below sets a timeout interval of 5 minutes:
<%
Session.Timeout=5
%>
224 LOVELY PROFESSIONAL UNIVERSITY