Latest web development tutorials

ASP Session Object

Session object is used to store information about a user session (session), or change the user session (session) setting.


Examples

Try - Example

Settings and return LCID
This example demonstrates "LCID" property. The property is set and returns an integer indicating the location or region. Like date, time, and money, etc. should be displayed according to the location or region.

Back SessionID
This example demonstrates "SessionID" attribute. This property returns a unique id for each user. The id is generated by the server.

session timeout
This example demonstrates the "Timeout" property. The property settings and return to session timeout (minutes).


Session Object

When you operate an application on your computer, you open it, do some changes, and then close it. It's like a conversation (Session). The computer knows who you are. It is clear that you open and close applications when. However, on the Internet, the question arises: could not hold because the HTTP address, Web server does not know who you are and what you did.

ASP by creating a unique cookie for each user to solve this problem. cookie is transferred to the user's computer, which contains identifiable user information. This interface is called the Session object.

Session object is used to store information about a user session (session), or change the user session (session) setting.

Variable stores a single user's information is stored in the Session object, and are available for applications in all pages. Stored in a public information session variable is usually name, id and parameters. The server creates a new Session for each new user, and to withdraw out of the Session object when the session expired.

Collections, properties, methods, and events described in the Session object as follows:

set

集合 描述
Contents 包含所有通过脚本命令追加到 session 的条目。
StaticObjects 包含了所有使用 HTML 的 <object> 标签追加到 session 的对象。

Attributes

属性 描述
CodePage 规定显示动态内容时使用的字符集。
LCID 设置或返回指定位置或者地区的一个整数。诸如日期、时间好以及货币的内容会根据位置或者地区来显示。
SessionID 为每个用户返回一个唯一的 id。此 id 由服务器生成。
Timeout 设置或返回应用程序中的 Session 对象的超时时间(分钟)。

method

方法 描述
Abandon 撤销一个用户的 session。
Contents.Remove 从 Contents 集合删除一个项目。
Contents.RemoveAll() 从 Contents 集合删除所有项目。

event

事件 描述
Session_OnEnd 当一个会话结束时此事件发生。
Session_OnStart 当一个会话开始时此事件发生。