Collection of Session objects and properties

Source: Internet
Author: User
Tags object character set comments contains key variables

Session StaticObjects Collection
The StaticObjects collection contains all objects created with the <OBJECT> tag in the scope of the Session object. This collection can be used to determine the value of an object-specific property, or to traverse the collection and get all the properties of all objects.

Grammar
Session.StaticObjects (Key)

Parameters
Key
The property to retrieve.
Comments
Use the loop control structure to traverse the keywords in the StaticObjects collection. Take a look at the example below.

<%
Dim Objprop
For each objprop in session.staticobjects
Response.Write (Objproperty & ":" & Session.StaticObjects (Objprop) & "<BR>")
Next

%>

Session Contents Collection
The Session.Contents collection includes all the items that were established for the session without <OBJECT> tags. This collection can be used to determine the value of a specified session item or traversal set Merge to retrieve a list of all items in a session.

Grammar
Session.Contents (Key)

Parameters
Key
The name of the property to get.
Comments
You can use a loop control structure to loop through the keywords of the Contents collection. The following example demonstrates this procedure.

<%
Dim Sessitem
For each sessitem in session.contents
Response.Write (Sessitem & ":" & Session.Contents (sessitem) & "<BR>")
Next

%>

The

CodePage
CodePage property determines the code page that will be used to display dynamic content.

Syntax
Session.CodePage (=codepage)

Parameters
CodePage
This is an unsigned integer that represents a valid code page for the system that is running the ASP script engine. The
Comment
code page is a character set that can include numbers, punctuation marks, and other letters. Different code pages can be used for different languages and regions. For example, ANSI code page 1252 is used for American English and most European languages; OEM code page 932 is for kanji. The

code page is a character chart that maps characters to single-byte or multibyte values. Many code pages share characters between 0x00-0x7f in the ASCII character set.

Abandon
The Abandon method deletes all objects stored in the session object and releases the source of those objects. If you do not explicitly call the Abandon method, the server deletes these objects once the session times out.

Grammar
Session.Abandon

Comments
When the Abandon method is invoked, the current session object is deleted sequentially, but the object is actually deleted when all script commands are processed in the current page. This means that when Abandon is invoked, the variables stored in the Session object can be accessed on the current page, but not on subsequent Web pages.

For example, in the following script, the third line prints the Mary value. This is because the session object is not deleted before the server finishes processing the script.

<%
Session.Abandon
Session ("myname") = "Mary"
Reponse.write (Session ("MyName"))
%>

If you access the MyName variable on a subsequent Web page, you will find that it is empty. This is because when the page that contains the previous example finishes processing, myname is deleted with the previous session object.

When you discard a session and open a subsequent Web page, the server creates a new sessions object. You can store variables and objects in a new Session object.

Example
The following example releases session state when the server finishes processing the current page.

<% Session.Abandon%>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.