예제 #1
0
 public HttpSession CreateSession(ContextRFC AContext, HttpRequestInfo AHttpRequestInfo, HttpResponseInfo AHttpResponseInfo)
 {
     if (SessionState)
     {
         HttpSession TempResult = null;
         DoOnCreateSession(AContext, out TempResult);
         if (TempResult == null)
         {
             TempResult = _SessionList.CreateUniqueSession(AHttpRequestInfo.RemoteIP);
         }
         else
         {
             _SessionList.Add(TempResult);
         }
         ServerCookie TempCookie = AHttpResponseInfo.Cookies.Add();
         TempCookie.CookieName = Http.SessionIdCookie;
         TempCookie.Value      = TempResult.SessionId;
         TempCookie.Path       = "/";
         TempCookie.MaxAge     = -1;
         AHttpRequestInfo.SetSession(TempResult);
         AHttpResponseInfo.SetSession(TempResult);
         return(TempResult);
     }
     return(null);
 }
예제 #2
0
        protected HttpSession GetSessionFromCookie(ContextRFC AContext, HttpRequestInfo AHttpRequestInfo, HttpResponseInfo AHttpResponseInfo, out bool OContinueProcessing)
        {
            OContinueProcessing = true;
            HttpSession TempResult = null;

            if (SessionState)
            {
                int    CurrentCookieIndex = AHttpRequestInfo.Cookies.GetCookieIndex(0, Http.SessionIdCookie);
                string SessionId          = "";
                while (TempResult == null &&
                       CurrentCookieIndex > -1)
                {
                    SessionId  = AHttpRequestInfo.Cookies[CurrentCookieIndex].Value;
                    TempResult = _SessionList.GetSession(SessionId, AHttpRequestInfo.RemoteIP);
                    if (TempResult == null)
                    {
                        DoInvalidSession(AContext, AHttpRequestInfo, AHttpResponseInfo, SessionId, out OContinueProcessing);
                    }
                    CurrentCookieIndex++;
                    CurrentCookieIndex = AHttpRequestInfo.Cookies.GetCookieIndex(CurrentCookieIndex, Http.SessionIdCookie);
                }
                if (_AutoStartSession &&
                    OContinueProcessing &&
                    TempResult == null)
                {
                    TempResult = CreateSession(AContext, AHttpRequestInfo, AHttpResponseInfo);
                }
            }
            AHttpRequestInfo.SetSession(TempResult);
            AHttpResponseInfo.SetSession(TempResult);
            return(TempResult);
        }