ASP 세션 개체


Session 개체는 사용자 세션에 대한 정보를 저장하거나 설정을 변경합니다.


더 많은 예


설정하고 반환하거나 위치 또는 지역을 지정하는 정수를 반환합니다. 날짜, 시간 및 통화와 같은 내용은 해당 위치 또는 지역에 따라 표시됩니다.


를 반환합니다. 각 사용자의 고유한 ID를 반환합니다. id는 서버에서 생성됩니다.


초과(분)를 설정하고 반환합니다.


세션 개체

컴퓨터에서 응용 프로그램으로 작업할 때 응용 프로그램을 열고 일부 변경한 다음 닫습니다. 이것은 세션과 매우 유사합니다. 컴퓨터는 당신이 누구인지 알고 있습니다. 응용 프로그램을 열 때와 닫을 때를 알고 있습니다. 그러나 인터넷에는 한 가지 문제가 있습니다. HTTP 주소는 상태를 유지하지 않기 때문에 웹 서버는 귀하가 누구이고 무엇을 하는지 모릅니다.

ASP는 각 사용자에 대해 고유한 쿠키를 만들어 이 문제를 해결합니다. 쿠키는 사용자의 컴퓨터로 전송되며 사용자를 식별하는 정보가 포함됩니다. 이 인터페이스를 Session 개체라고 합니다.

Session 개체는 사용자 세션에 대한 정보를 저장하거나 설정을 변경합니다.

Session 객체에 저장된 변수는 한 명의 사용자에 대한 정보를 담고 있으며 한 애플리케이션의 모든 페이지에서 사용할 수 있습니다. 세션 변수에 저장되는 공통 정보는 이름, 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