ASPセッションオブジェクト
Sessionオブジェクトは、ユーザーセッションに関する情報を格納したり、ユーザーセッションの設定を変更したりします。
その他の例
ます場所または地域を指定する整数を設定または返します。日付、時刻、通貨などのコンテンツは、その場所または地域に応じて表示されます。
を返します各ユーザーの一意のIDを返します。IDはサーバーによって生成されます。
タイムアウト(分単位)を設定して返します。
セッションオブジェクト
コンピューターでアプリケーションを操作しているときは、アプリケーションを開き、いくつかの変更を加えてから閉じます。これはセッションによく似ています。コンピュータはあなたが誰であるかを知っています。アプリケーションをいつ開くか、いつ閉じるかを認識します。ただし、インターネットには1つの問題があります。それは、HTTPアドレスが状態を維持しないため、Webサーバーがユーザーが誰で何をしているのかを認識しないことです。
ASPは、ユーザーごとに一意のCookieを作成することにより、この問題を解決します。Cookieはユーザーのコンピューターに送信され、ユーザーを識別する情報が含まれています。このインターフェイスは、Sessionオブジェクトと呼ばれます。
Sessionオブジェクトは、ユーザーセッションに関する情報を格納したり、ユーザーセッションの設定を変更したりします。
Sessionオブジェクトに格納されている変数は、1人のユーザーに関する情報を保持し、1つのアプリケーションのすべてのページで使用できます。セッション変数に格納される一般的な情報は、名前、ID、および設定です。サーバーは、新しいユーザーごとに新しいSessionオブジェクトを作成し、セッションの有効期限が切れるとSessionオブジェクトを破棄します。
Sessionオブジェクトのコレクション、プロパティ、メソッド、およびイベントについて、以下で説明します。
コレクション
Collection | Description |
---|---|
Contents | Contains all the items appended to the session through a script command |
StaticObjects | Contains all the objects appended to the session with the HTML <object> tag |
プロパティ
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 |
Timeout | Sets or returns the timeout period (in minutes) for the Session object in this application |
メソッド
Method | Description |
---|---|
Abandon | Destroys a user session |
Contents.Remove | Deletes an item from the Contents collection |
Contents.RemoveAll() | Deletes all items from the Contents collection |
イベント
Event | Description |
---|---|
Session_OnEnd | Occurs when a session ends |
Session_OnStart | Occurs when a session starts |