Example #1
0
 /// <summary>
 /// Resets a session timeout
 /// </summary>
 /// <param name="context">The current request context</param>
 /// <param name="id">The session id</param>
 public override void ResetItemTimeout(HttpContext context, string id)
 {
     // Force a session get to update its timeout
     var ids       = SharedSessionIDManager.GetSessionIdAndServer(id);
     var timestamp = SharedSessionIDManager.GetSessionTimestamp(id);
     var data      = SharedSessionServerManager.GetData(ids[1], ids[0], timestamp);
 }
Example #2
0
        /// <summary>
        /// Removes an item from the session store
        /// </summary>
        /// <param name="context">The current request context</param>
        /// <param name="id">The session id</param>
        /// <param name="lockId">The lock id</param>
        /// <param name="item">The item to remove</param>
        public override void RemoveItem(
            HttpContext context,
            string id,
            object lockId,
            SessionStateStoreData item)
        {
            var ids = SharedSessionIDManager.GetSessionIdAndServer(id);

            SharedSessionServerManager.Remove(ids[1], ids[0]);
        }
Example #3
0
        /// <summary>
        /// Adds a new session-state item to the data store.
        /// </summary>
        /// <param name="context">The current request context</param>
        /// <param name="id">The System.Web.SessionState.HttpSessionState.SessionID for the current request.</param>
        /// <param name="timeout">The timeout for the current request</param>
        public override void CreateUninitializedItem(HttpContext context, string id, int timeout)
        {
            var ids = SharedSessionIDManager.GetSessionIdAndServer(id);

            if (ids == null || ids.Length != 3)
            {
                throw new ArgumentException("Invalid ID", "id");
            }
            var timestamp = SharedSessionIDManager.GetSessionTimestamp(id);

            SharedSessionServerManager.SetData(ids[1], ids[0], string.Empty, timestamp);
        }
Example #4
0
        /// <summary>Updates the session-item information in the session-state data store
        /// with values from the current request, and clears the lock on the data.
        /// </summary>
        /// <param name="context">The current request context</param>
        /// <param name="id">The session id</param>
        /// <param name="item">The data to store</param>
        /// <param name="lockId">The lock id</param>
        /// <param name="newItem">Indicates if it is a new item</param>
        public override void SetAndReleaseItemExclusive(
            HttpContext context,
            string id,
            SessionStateStoreData item,
            object lockId,
            bool newItem)
        {
            //Stores the data in a shared session server
            var ids       = SharedSessionIDManager.GetSessionIdAndServer(id);
            var timestamp = DateTime.Now;             // new timestamp

            SharedSessionServerManager.SetData(ids[1], ids[0], Serialize((SessionStateItemCollection)item.Items), timestamp);

            // Update the session id information with the new timestamp
            SharedSessionIDManager.UpdateCurrentSessionIdTimestamp(context, id, timestamp);
        }
Example #5
0
        /// <summary>
        /// Returns read-only session-state data from the session data store.
        /// </summary>
        /// <param name="context">The current request context</param>
        /// <param name="id">The session id</param>
        /// <param name="locked">Indicates if the item is locked in the data store (always false)</param>
        /// <param name="lockAge">Indicates the age of the lock (always TimeSpan.MaxValue)</param>
        /// <param name="lockId">An object that represents the lock ID</param>
        /// <param name="actions">Actions to perform after the request (always SessionStateActions.None)</param>
        /// <returns></returns>
        public override SessionStateStoreData GetItem(
            HttpContext context,
            string id,
            out bool locked,
            out TimeSpan lockAge,
            out object lockId,
            out SessionStateActions actions)
        {
            var ids       = SharedSessionIDManager.GetSessionIdAndServer(id);
            var timestamp = SharedSessionIDManager.GetSessionTimestamp(id);
            var data      = SharedSessionServerManager.GetData(ids[1], ids[0], timestamp);

            locked  = false;
            lockAge = TimeSpan.MaxValue;
            lockId  = new Object();
            actions = SessionStateActions.None;

            return(Deserialize(context, data.Data, data.TimeOut));
        }