Share via


ISessionIDManager.SaveSessionID(HttpContext, String, Boolean, Boolean) 메서드

정의

새로 만든 세션 식별자를 HTTP 응답에 저장합니다.

public:
 void SaveSessionID(System::Web::HttpContext ^ context, System::String ^ id, [Runtime::InteropServices::Out] bool % redirected, [Runtime::InteropServices::Out] bool % cookieAdded);
public void SaveSessionID (System.Web.HttpContext context, string id, out bool redirected, out bool cookieAdded);
abstract member SaveSessionID : System.Web.HttpContext * string * bool * bool -> unit
Public Sub SaveSessionID (context As HttpContext, id As String, ByRef redirected As Boolean, ByRef cookieAdded As Boolean)

매개 변수

context
HttpContext

HTTP 요청(예: HttpContextRequest 속성)을 처리하는 데 사용되는 서버 개체를 참조하는 Response 개체입니다.

id
String

세션 식별자입니다.

redirected
Boolean

이 메서드가 반환될 때 세션 식별자가 추가된 현재 URL로 응답이 리디렉션되면 true이고, 그렇지 않으면 false인 부울 값이 포함됩니다.

cookieAdded
Boolean

이 메서드가 반환될 때, 쿠키가 HTTP 응답에 추가되었으면 true이고, 그렇지 않으면 false인 부울 값이 포함됩니다.

예제

다음 코드 예제에서는 부분적으로 구현 된 SaveSessionID 메서드. 사용자 지정 세션 ID 관리자에서 쿠키 없는 세션 식별자를 지 원하는 경우에 전송 및 ISAPI 필터와 같은 URL에서 세션 식별자를 검색에 대 한 솔루션을 구현 하는 것이 해야 합니다.

public void SaveSessionID(HttpContext context, string id, out bool redirected, out bool cookieAdded)
{
  redirected = false;
  cookieAdded = false;

  if (pConfig.Cookieless == HttpCookieMode.UseUri)
  {
    // Add the SessionID to the URI. Set the redirected variable as appropriate.

    redirected = true;
    return;
  }
  else
  {
    context.Response.Cookies.Add(new HttpCookie(pConfig.CookieName, id));
    cookieAdded = true;
  }
}
Public Sub SaveSessionID(context As HttpContext, _
                         id As String, _
                         ByRef redirected As Boolean, _
                         ByRef cookieAdded As Boolean) _
  Implements ISessionIDManager.SaveSessionID

  redirected = False
  cookieAdded = False

  If pConfig.Cookieless = HttpCookieMode.UseUri Then

    ' Add the SessionID to the URI. Set the redirected variable as appropriate.

    redirected = True
    Return
  Else
    context.Response.Cookies.Add(New HttpCookie(pConfig.CookieName, id))
    cookieAdded = True
  End If
End Sub

설명

SaveSessionID 메서드를 호출 합니다 SessionStateModule 하는 동안 개체는 HttpApplication.AcquireRequestState 이벤트입니다. SaveSessionID 메서드는 URL (쿠키 없는 세션 상태가 사용) 또는 만료 되지 않는 세션 쿠키에서 세션 식별자를 저장 합니다.

값을 반환 가능 하다 면 하 CreateSessionID 구현에는 HTTP 응답 또는 요청에 잘못 된 문자가 포함 되어 있습니다.를 사용 해야 합니다 UrlEncode 세션 식별자 값을 인코딩할 메서드 프로그램 SaveSessionID 메서드 구현 하며 UrlDecode 메서드를 디코딩하는 데 세션 식별자 값에 GetSessionID 메서드 구현 합니다.

적용 대상

추가 정보