Esempio n. 1
0
        public SessionInfo Abandon()
        {
            var cookie = MiniImsServer.CurrentContext.Request.Cookies["_s"];

            var value = Guid.Empty;

            if (cookie != null && Guid.TryParse(cookie.Value, out value))
            {
                ISessionManagerService sessionService = ApplicationContext.Current.GetService <ISessionManagerService>();
                var sessionInfo = sessionService.Delete(value);
                if (MiniImsServer.CurrentContext.Request.Cookies["_s"] == null)
                {
                    MiniImsServer.CurrentContext.Response.SetCookie(new Cookie("_s", Guid.Empty.ToString(), "/")
                    {
                        Expired = true, Expires = DateTime.Now.AddSeconds(-20)
                    });
                }

                if (sessionInfo != null)
                {
                    AuditUtil.AuditLogout(sessionInfo.Principal);
                }
            }

            return(new SessionInfo());
        }