当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP > ASP Session

ASP
ASP 介绍
ASP Install
ASP 语法
ASP 变量
ASP Procedures
ASP Forms
ASP Cookies
ASP Session
ASP Application
ASP #include
ASP Global.asa
ASP Send e-mail
ASP Response
ASP Request
ASP Application
ASP Session
ASP Server
ASP Error
ASP FileSystem
ASP TextStream

ASP Session


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 787 ::
收藏到网摘: n/a

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.
Session 对象是用来存储用户的Session信息以及用来改变用户Session的设置的。对于Session对象中的变量所存储的单个用户的信息,在同一请求下的所有页面都可以访问到它。


Examples

Set and return the LCID
设置以及返回LCID
This example demonstrates the "LCID" property. This property sets or returns an integer that specifies a location or region. Contents like date, time, and currency will be displayed according to that location or region.
这个例子描述了“LCID”属性。这个属性是用来设置或者返回一个能够指定“本地”属性以及“区域”属性的整数值。类似于日期、事件以及货币的内容将根据“本地”属性以及“区域”属性被展示出来。

Return the SessionID
返回SessionID
This example demonstrates the "SessionID" property. This property returns a unique id for each user. The id is generated by the server.
这个例子描述了“SessionID”属性。这个属性将为每个用户返回一个独立的id。这个id是在服务器产生的。

A session's timeout
Session timeout(过期)属性
This example demonstrates the "Timeout" property. This example sets and returns the timeout (in minutes) for the session.
这个例子描述了“Timeout”属性。这个例子为每个Session程序设置了Timeout(过期)值,并同时返回这个值。(注:这个Timeout属性的单位是分钟)


Session Object
Session对象

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.
当你运行一个应用程序,打开它,对它作了一些改变以后关闭它。这个过程就像在和程序进行交流。电脑知道你是谁,他明白你什么时候开始运行程序,什么时候结束。但是,在互联网上就会存在这样一个问题:网络服务器不知道你是谁,不知道你干了什么,因为HTTP地址不能保持(对所有的操作进行纪录)状态。

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.
然而,ASP通过为每一个用户建立一个完全独立“Cookie”解决了上述问题。这些“Cookie”被发送到客户端,它保存了所有能够辨别用户的信息。我们把这种能够实现相互沟通交界面就叫做Session对象,也就是通常我们所说的会话对象。

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.
Session对象是用来存储用户的”Session”的,它也可以对用户的Session进行改变和设置。对于Session对象中的变量所存储的单个用户的信息,在同一请求下的所有页面都可以访问到它。一般情况下,存储在Session变量中的信息主要是姓名、id以及一些相关的属性和参数。服务器会为每一个用户建立一个全新的Session对象,当Session过期时,它也会删除这些Session对象。

The Session object's collections, properties, methods, and events are described below:
这个Session对象的集合、属性、使用方法以及事件将在以下的表格中描述出来:

Collections
集合

Collection
集合
Description
描述
Contents Contains all the items appended to the session through a script command
包括所有通过脚本命令添加到Session中的项目
StaticObjects Contains all the objects appended to the session with the HTML <object> tag
包括所有通过HTML<object>标签添加到Session中的对象

Properties
属性

Property
属性
Description
描述
CodePage Specifies the character set that will be used when displaying dynamic content
指定一个特征,当所有的内容被动态显示的时候使用它
LCID Sets or returns an integer that specifies a location or region. Contents like date, time, and currency will be displayed according to that location or region
这个属性是用来设置或者返回一个能够指定“本地”属性以及“区域”属性的整数值。类似于日期、事件以及货币的内容将根据“本地”属性以及“区域”属性被展示出来。
SessionID Returns a unique id for each user. The unique id is generated by the server
这个属性将为每个用户返回一个独立的id。这个id是在服务器产生的。
Timeout Sets or returns the timeout period (in minutes) for the Session object in this application
这个例子为每个Session程序设置了Timeout(过期)值,并同时返回这个值。(注:这个Timeout属性的单位是分钟)

Methods
方法

Method
方法
Description
描述
Abandon Destroys a user session
取消一个用户的Session
Contents.Remove Deletes an item from the Contents collection
从Session Contents集合里删除其中一个项目
Contents.RemoveAll() Deletes all items from the Contents collection
删除Session Contents集合里的所有项目

Events
事件

Event Description
Session_OnEnd Occurs when a session ends
当Session结束时执行
Session_OnStart Occurs when a session starts
当Session开始时执行

评论 (0) All

登陆 | 还没注册?