ASP-Session-Objekt

Das Session-Objekt wird verwendet, um Informationen über eine Benutzer-Sitzung (Session) zu speichern oder Einstellungen zu ändern. Variablen, die im Session-Objekt gespeichert sind, enthalten Informationen über einen einzelnen Benutzer und sind für alle Seiten im Dokument verfügbar.

Example

Set and return LCID
This example demonstrates the "LCID" property. This property sets and returns an integer indicating the location or region. Similar content such as dates, times, and currencies should be displayed according to the location or region.
Return SessionID
This example demonstrates the "SessionID" property. This property returns a unique id for each user. This id is generated by the server.
Session timeout
This example demonstrates the "Timeout" property. This example sets and returns the session timeout time (in minutes).

Session object

When you are operating an application, you start it, make some changes, and then close it. This process is similar to a conversation (Session). The computer knows who you are. It also knows when you start and close the application. However, on the internet, a problem arises: the web server does not know who you are or what you are doing, which is due to the fact that HTTP addresses cannot retain state (information).

ASP solves this problem by creating a unique cookie for each user. The cookie is sent to the server and contains information that identifies the user. This interface is called the Session object.

The Session object is used to store information about a user's session (session) or modify related settings. Variables stored in the session object hold information about a single user and are accessible on all pages within the session. Information typically stored in session variables includes name, id, and parameters. The server creates a new Session object for each new user and revokes this object when the session expires.

The following is a collection of the Session object's properties, methods, and events:

Collection

Collection Beschreibung
Contents Contains all entries appended to the session via script commands.
StaticObjects Contains all objects appended to the session using the HTML <object> tag.

Property

Property Beschreibung
CodePage Specifies the character set used when displaying dynamic content.
LCID Set or return an integer for a specified location or region. Content such as dates, times, and currencies will be displayed according to the location or region.
SessionID Returns a unique id for each user. This id is generated by the server.
Timeout Set or return the timeout time (in minutes) of the session object in the application.

Method

Method Beschreibung
Abandon Withdraw a user's session.
Contents.Remove Entferne ein Element aus der Contents-Kollektion.
Contents.RemoveAll() Entferne alle Elemente aus der Contents-Kollektion.

Ereignis

Ereignis Beschreibung
Session_OnEnd Dieses Ereignis tritt auf, wenn eine Sitzung endet.
Session_OnStart Dieses Ereignis tritt auf, wenn eine Sitzung beginnt.