2 // System.Web.SessionState.SessionInProcHandler
5 // Stefan Görling (stefan@gorling.se)
6 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
8 // (C) 2003 Stefan Görling
9 // Copyright (c) 2004 Novell, Inc. (http://www.novell.com)
14 using System.Collections;
15 using System.Web.Caching;
17 namespace System.Web.SessionState
19 class SessionInProcHandler : ISessionHandler
22 CacheItemRemovedCallback removedCB;
24 public void Dispose () { }
26 public void Init (SessionStateModule module, HttpApplication context, SessionConfig config)
28 removedCB = new CacheItemRemovedCallback (module.OnSessionRemoved);
32 public void UpdateHandler (HttpContext context, SessionStateModule module) { }
34 public HttpSessionState UpdateContext (HttpContext context, SessionStateModule module,
35 bool required, bool read_only, ref bool isNew)
40 Cache cache = HttpRuntime.Cache;
41 HttpSessionState state = null;
42 string id = SessionId.Lookup (context.Request, config.CookieLess);
45 state = (HttpSessionState) cache ["@@@InProc@" + id];
50 // Create a new session.
51 string sessionID = SessionId.Create (module.Rng);
52 state = new HttpSessionState (sessionID, // unique identifier
53 new SessionDictionary(), // dictionary
54 HttpApplicationFactory.ApplicationState.SessionObjects,
55 config.Timeout, //lifetime before death.
57 false, // is cookieless
58 SessionStateMode.InProc,
59 read_only); //readonly
61 TimeSpan timeout = new TimeSpan (0, config.Timeout, 0);
62 cache.Insert ("@@@InProc@" + sessionID, state, null, DateTime.Now + timeout,
63 timeout, CacheItemPriority.AboveNormal, removedCB);