Events Methods Properties Collections

What is session object
The unique instance

of application which individual user run is known as session. For example consider

a user start up the application and open a file to edit.he continues to make

changes and finally save and close the file.the time period during which he

is editing the file can be thought of as a session.  The session object

is used to interact with session. The session can be used to store a piece of

information that is available to every page in the application.


Asp Session Object – events

1) Session_Onstart

– triggered when a new user enters into ASP application.For example save the

following code in global.asa.

Sub

Session_Onstart

Session(“start”) = now

Application.Lock

Application(“visitor”) = Application(“visitor”)

+ 1

Application.UnLock

End Sub

2) Session_OnEnd

– Initiated when ASP session object terminated.

Sub

Session_OnEnd

Application.Lock

Application(“visitor”) = Application(“visitor”)

– 1

Application.UnLock

End Sub

Top


Asp Session Object – Methods

1)Abandon

– destroys all the objects stored in Session objects and releases the server

resources they were occupying.All the session variable values  will be

lost.We can call this method using following statement.

<%Session.abandon%>

2)Contents.Remove

– The Remove method deletes a specific item from the Session object’s Contents

collection.

For eg.

<%

Session(“TestVar”) = “Test String”

Session(“AnotherVar”) = “Another String”

Session.Contents.Remove(TestVar)

%>

Top


Asp Session Object – Properties

1)SessionId

– When a session is created the server generate a unique Id number for each

session.SessionId property returns the session Id number.The syntax is:

<%=Session.SessionId%>

2)TimeOut

– sets timeout period assigned to the session object for any application in

minutes.If the user does not refresh the page before the time out period expires

, the session ends.We can set time using following statement.

<%Session.TimeOut

= 25%>

3) CodePage

– determines the codepage that will be used to display the contents.This is

used only when you are using non_Roman alphabets.In order to set the session’s

code page you must first enable code page support with.

The following is an example to set the code page to Roman alphabet.

<%@

code page = codepage

Session.codepage = 1252

%>

4) LCID

– determines time zone and language for the system. For eg. to set US English

<%Session.LCID

= 1033%>

 

Top


Asp Session Object – Collections

1)Contents

collection- Contains the items that you have added to the session with script

commands.

2)StaticObjects

collection – Contains the objects created with the <OBJECT> tag and given

session scope.

Top


 

Leave a Comment