/// <summary>
        /// Recursivly remove expired session data from session collection.
        /// </summary>
        private void RemoveExpiredSessionData()
        {
            foreach (DictionaryEntry entry in SessionItems)
            {
                SessionItemEx item = (SessionItemEx)entry.Value;

                if (DateTime.Compare(item.Expires, DateTime.Now) <= 0)
                {
                    var sessionId = entry.Key.ToString();
                    SessionItems.Remove(entry.Key);

                    HttpSessionStateContainer stateProvider =
                        new HttpSessionStateContainer(sessionId,
                                                      item.Items,
                                                      item.StaticObjects,
                                                      Timeout,
                                                      false,
                                                      CookieMode,
                                                      SessionStateMode.Custom,
                                                      false);

                    SessionStateUtility.RaiseSessionEnd(stateProvider, this, EventArgs.Empty);
                    RemoveExpiredSessionData();
                    break;
                }
            }
        }
        protected override SessionItem AddNewSessionItem(string sessionId,
                                                         HttpStaticObjectsCollection staticObjects)
        {
            var sessionItem = new SessionItem();

            sessionItem.Items         = new SossSessionStateItemCollection(sessionId, Timeout);
            sessionItem.StaticObjects = staticObjects;

            var data = new SessionItemEx(sessionItem);

            //@@namedCache.Insert(sessionId, data, createPolicy, true, false);

            return(sessionItem);
        }
        protected override SessionItem AddNewSessionItem(string sessionId,
                                                         HttpStaticObjectsCollection staticObjects)
        {
            var sessionData = new SessionItemEx();

            sessionData.Items         = new ThreadSafeSessionStateItemCollection();
            sessionData.StaticObjects = staticObjects;
            sessionData.Expires       = DateTime.Now.AddMinutes(Timeout);

            try
            {
                HashtableLock.EnterWriteLock();
                SessionItems[sessionId] = sessionData;
            }
            finally
            {
                HashtableLock.ExitWriteLock();
            }

            return(sessionData);
        }