Source/NFX.Wave/Filters/SessionFilter.cs
/// <summary>
/// Override to put session object back into whatever storage medium is provided (i.e. DB) and
/// respond with appropriate session identifying token(i.e. a cookie)
/// </summary>
Override to put session object back into whatever storage medium is provided  and
respond with appropriate session identifying token
Override to put session object back into whatever storage medium is provided and respond with appropriate session identifying token
protected virtual void StowSession(WorkContext work)
      {
        var session = work.m_Session;
        if (session==null) return;
        try
        {
          if (!session.IsEnded)
          {
            var regenerated = session.OldID.HasValue;
            if (regenerated)
             App.ObjectStore.CheckInUnderNewKey(session.OldID.Value, session.ID, session, m_SessionTimeoutMs);
            else
             App.ObjectStore.CheckIn(session.ID, session, m_SessionTimeoutMs);
            if (session.IsNew || regenerated)
            {
              var apiVersion = work.Request.Headers[SysConsts.HEADER_API_VERSION];
              if (apiVersion!=null)
                work.Response.AddHeader(SysConsts.HEADER_API_SESSION, EncodeSessionID( work, session, true));
              else
                work.Response.SetClientVar(m_CookieName, EncodeSessionID( work, session, false ));
            }
          }
          else
          {
            App.ObjectStore.Delete(session.ID);
            work.Response.SetClientVar(m_CookieName, null);
            if (Server.m_InstrumentationEnabled)
               Interlocked.Increment(ref Server.m_stat_SessionEnd);
          }
        }
        finally
        {
          session.Release();
          work.m_Session = null;
          ApplicationModel.ExecutionContext.__SetThreadLevelSessionContext(null);
        }
      }
protected virtual void StowSession ( WorkContext work ) { var session = work . m_Session ; if ( session == null ) return ; try { if ( ! session . IsEnded ) { var regenerated = session . OldID . HasValue ; if ( regenerated ) App . ObjectStore . CheckInUnderNewKey ( session . OldID . Value , session . ID , session , m_SessionTimeoutMs ) ; else App . ObjectStore . CheckIn ( session . ID , session , m_SessionTimeoutMs ) ; if ( session . IsNew || regenerated ) { var apiVersion = work . Request . Headers [ SysConsts . HEADER_API_VERSION ] ; if ( apiVersion != null ) work . Response . AddHeader ( SysConsts . HEADER_API_SESSION , EncodeSessionID ( work , session , true ) ) ; else work . Response . SetClientVar ( m_CookieName , EncodeSessionID ( work , session , false ) ) ; } } else { App . ObjectStore . Delete ( session . ID ) ; work . Response . SetClientVar ( m_CookieName , null ) ; if ( Server . m_InstrumentationEnabled ) Interlocked . Increment ( ref Server . m_stat_SessionEnd ) ; } } finally { session . Release ( ) ; work . m_Session = null ; ApplicationModel . ExecutionContext . __SetThreadLevelSessionContext ( null ) ; } }
Override to put session object back into whatever storage medium is provided (i.e.
Override to put session object back into whatever storage medium is provided ( i . e .
//the cookie is set only for non-api call
work
WorkContext