Example #1
0
        static void DoWork(string[] args)
        {
            Console.WriteLine("PreBootstrap State: " + SessionManager.Instance.State.ToString());
            SessionManager.Instance.Bootstrap(); // new Osrs.Reflection.TypeNameReference("Osrs.Security.Sessions.Module", "Osrs.Security.Sessions.Providers.MemorySessionProviderFactory"), 0);
            Console.WriteLine("PostBootstrap State: " + SessionManager.Instance.State.ToString());
            SessionManager.Instance.Initialize();
            Console.WriteLine("PostInitialize State: " + SessionManager.Instance.State.ToString());
            SessionManager.Instance.Start();
            Console.WriteLine("PostStart State: " + SessionManager.Instance.State.ToString());

            SessionProviderBase prov = SessionManager.Instance.GetProvider();

            Console.WriteLine("Provider null: " + (prov == null));
            if (prov != null)
            {
                ModuleRuntimeSession sess = prov.Create();
                Console.WriteLine("Session null: " + (sess == null));

                Console.WriteLine("exists: " + prov.Exists(sess.SessionId));
                Console.WriteLine("extend: " + prov.Extend(sess.SessionId));
                Console.WriteLine("expire: " + prov.Expire(sess.SessionId));
                Console.WriteLine("exists: " + prov.Exists(sess.SessionId));
            }
        }
Example #2
0
        public override void Handle(HttpContext context, CancellationToken cancel)
        {
            if (context != null)
            {
                HttpRequest  request  = context.Request;
                HttpResponse response = context.Response;

                if (request.Headers.ContainsKey(Session.SessionIdName))
                {
                    Guid ssid;
                    if (Guid.TryParse(request.Headers[Session.SessionIdName], out ssid))
                    {
                        if (prov.Exists(ssid) && prov.Extend(ssid)) //note that this will autoextend and will return false if expired
                        {
                            response.Headers[Session.SessionIdName] = request.Headers[Session.SessionIdName];
                        }
                    }
                }
                if (this.Next != null)
                {
                    this.Next.Handle(context, cancel);
                }
            }
        }