Esempio n. 1
0
        public static void SaveSession(this IRequest httpReq, IAuthSession session, TimeSpan?expiresIn = null)
        {
            if (httpReq == null)
            {
                return;
            }

            using (var cache = httpReq.GetCacheClient())
            {
                var sessionKey = SessionFeature.GetSessionKey(httpReq.GetSessionId());
                cache.CacheSet(sessionKey, session, expiresIn ?? HostContext.GetDefaultSessionExpiry());
            }

            httpReq.Items[RequestItemsSessionKey] = session;
        }
        public virtual void OnSaveSession(IRequest httpReq, IAuthSession session, TimeSpan?expiresIn = null)
        {
            if (httpReq == null)
            {
                return;
            }

            using (var cache = this.GetCacheClient())
            {
                var sessionKey = SessionFeature.GetSessionKey(session.Id ?? httpReq.GetOrCreateSessionId());
                session.LastModified = DateTime.UtcNow;
                cache.CacheSet(sessionKey, session, expiresIn ?? HostContext.GetDefaultSessionExpiry());
            }

            httpReq.Items[SessionFeature.RequestItemsSessionKey] = session;
        }