/// <summary>
        /// Fills the system ASP.NET session from NCache.
        /// </summary>
        /// <param name="session"></param>
        /// <param name="cache"></param>
        /// <param name="strict"></param>
        void IDistributionStrategy.FillSessionFromCache(ISessionCache cache, HttpSessionState session, NSessionStateModule module, bool strict)
        {
            try
            {
                string sessionId = session.SessionID;
                if (strict)
                {
                    session.Clear();
                }

                IDictionaryEnumerator i = (IDictionaryEnumerator)cache.GetEnumerator();
                while (i != null && i.MoveNext())
                {
                    SessionKey key = i.Key as SessionKey;
                    if (key != null && key.SessionID == sessionId)
                    {
                        session[key.Key] = i.Value;
                    }
                }
            }
            catch (Exception exc)
            {
                if (strict)
                {
                    session.Clear();
                }
                module.RaiseExceptions(exc, "SingleValueDistribution.FillSessionFromCache");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Stores session variables to ASP.NET session.
        /// </summary>
        internal protected override void Persist(PhpArray variables, ScriptContext context, HttpContext httpContext)
        {
            HttpSessionState state = httpContext.Session;

            if (state.Mode == SessionStateMode.InProc)
            {
                context.ReleaseArray(variables);

                // removes all items (some could be changed or removed in PHP):
                // TODO: some session variables could be added in ASP.NET application
                state.Clear();

                // populates session collection from variables:
                foreach (KeyValuePair <IntStringKey, object> entry in variables)
                {
                    // skips resources:
                    if (!(entry.Value is PhpResource))
                    {
                        state.Add(entry.Key.ToString(), entry.Value);
                    }
                }
            }
            else
            {
                // if the session is maintained out-of-process, serialize the entire $_SESSION autoglobal
                MemoryStream    stream    = new MemoryStream();
                BinaryFormatter formatter = new BinaryFormatter(null,
                                                                new StreamingContext(StreamingContextStates.Persistence));

                formatter.Serialize(stream, variables);

                // add the serialized $_SESSION to ASP.NET session:
                state[PhpNetSessionVars] = stream.ToArray();
            }
        }
Beispiel #3
0
 public void Clear()
 {
     if (_session != null)
     {
         _session.Clear();
     }
 }
Beispiel #4
0
        // Cierra la session, clareando las variables usadas en Session.
        public static void closeSession()
        {
            HttpSessionState session = HttpContext.Current.Session;

            session.Clear();
            session.Abandon();
        }
Beispiel #5
0
        public static void Logout(BizPortalSessionContext context, HttpSessionState session, HttpApplicationState application)
        {
            context.PersistenceSession.Flush();
            if (0 != context.UserSessionID)
            {
                var userId      = context.UserID;
                var activeUsers = (Dictionary <long, string>)application["ActivingUsers"];
                if (activeUsers.ContainsKey(userId))
                {
                    UpdateLogoutTimeStamp(context);
                    activeUsers.Remove(userId);
                }

                UserSession userSession = context.PersistenceSession.Get <UserSession>(context.UserSessionID);
                if (null != userSession)
                {
                    //context.Log((int)SystemFunctionID.UserLogout, 0, 0, ActionLog.SystemFunction.Logout, string.Format("<b>ออกจากระบบ</b><br /><b>ชื่อเข้าใช้งาน</b> : {0}", context.User.LoginName));
                    if (userSession.SessionPeriod.IsEffective())
                    {
                        userSession.SignOut(context, "User logs out");
                    }
                    context.Close();
                }
            }
            session.Clear();
        }
/// <summary>
/// Fills the system ASP.NET session from NCache.
/// </summary>
/// <param name="session"></param>
/// <param name="cache"></param>
/// <param name="strict"></param>

        void IDistributionStrategy.FillSessionFromCache(ISessionCache cache, HttpSessionState session, NSessionStateModule module, bool strict)
        {
            string sessionId = session.SessionID;

            SessionKey key = new SessionKey(sessionId, module.ApplicationId);

            if (strict)
            {
                session.Clear();
            }

            /// save the binary form of data, for comparision on FillCacheFromAspNet()
            _table = (byte[])cache.Get(key.ToString());

            if (_table == null)
            {
                _isNewSession = true;
                return;
            }

            Hashtable ht = (Hashtable)CompactBinaryFormatter.FromByteBuffer(_table, module.CacheID);

            if (ht == null)
            {
                return;
            }

            IDictionaryEnumerator i = ht.GetEnumerator();

            while (i.MoveNext())
            {
                session[i.Key.ToString()] = i.Value;
            }
        }
/// <summary>
/// Fills NCache from the system ASP.NET session.
/// </summary>
/// <param name="cache"></param>
/// <param name="session"></param>
/// <param name="strict"></param>
/// <param name="async"></param>

        void IDistributionStrategy.FillCacheFromSession(ISessionCache cache, HttpSessionState session, NSessionStateModule module, bool strict, bool isAbandoned)
        {
            string     sessionId = session.SessionID;
            SessionKey key       = new SessionKey(sessionId, module.ApplicationId);

            try
            {
                if (session.IsReadOnly && cache.Contains(sessionId, key.ToString()) && !isAbandoned)
                {
                    return;
                }

                if (/*session.Count == 0 ||*/ isAbandoned)//[Ata]: Session is not removed from store if it is cleared
                {
                    cache.Remove(sessionId, key.ToString(), false);
                    if (module.DetailedLogsEnabled)
                    {
                        NSessionStateModule.NCacheLog.Debug(sessionId + " :session removed from cache");
                    }
                    return;
                }

                //use-case: A session my get emptied while doing different updates... although whien added first time is is not empty
                //So we must update that session rather doing no operation thinking it is empty session and need not to be added.
                if (session.Count == 0 && _isNewSession) //We need not to keep any new empty session in the cache. [Asif Imam] April 09, 08
                {
                    return;
                }

                IDictionary ht = new Hashtable();
                foreach (string skey in session.Keys)
                {
                    ht[skey] = session[skey];
                }

                byte[] _stable = CompactBinaryFormatter.ToByteBuffer(ht, module.CacheID);

                if (_table != null)
                {
                    if (BinaryComparer(_stable, _table))
                    {
                        return;
                    }
                }

                CacheItem sessionItem = new CacheItem(_stable);
                sessionItem.Priority = CacheItemPriority.NotRemovable;

                sessionItem.Expiration = new Runtime.Caching.Expiration(Runtime.Caching.ExpirationType.Sliding, TimeSpan.FromMinutes(session.Timeout));
                cache.Insert(sessionId, key.ToString(), sessionItem, false);
            }
            finally
            {
                if (session != null && strict)
                {
                    session.Clear();
                }
            }
        }
 public void ClearSession(HttpSessionState s)
 {
     if (s != null)
     {
         s.Clear();
         s.Abandon();
     }
 }
        public static void Logout(string username, string password)
        {
            HttpSessionState session = HttpContext.Current.Session;

            session["username"] = "";
            session["userid"]   = "";
            session.Clear();
        }
Beispiel #10
0
        /// <summary>
        /// Fills NCache from the system ASP.NET session.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="session"></param>
        /// <param name="strict"></param>
        /// <param name="async"></param>
        void IDistributionStrategy.FillCacheFromSession(ISessionCache cache, HttpSessionState session, NSessionStateModule module, bool strict, bool isAbandoned)
        {
            string     sessionId = session.SessionID;
            SessionKey key       = new SessionKey(sessionId, module.ApplicationId);

            try
            {
                if (session.IsReadOnly && cache.Contains(sessionId, key.ToString()) && !isAbandoned)
                {
                    return;
                }

                if (isAbandoned)// Session is not removed from store if it is cleared
                {
                    cache.Remove(sessionId, key.ToString(), false);
                    if (module.DetailedLogsEnabled)
                    {
                        NSessionStateModule.NCacheLog.Debug(sessionId + " :session removed from cache");
                    }
                    return;
                }

                if (session.Count == 0 && _isNewSession) //We need not to keep any new empty session in the cache.
                {
                    return;
                }

                IDictionary ht = new Hashtable();
                foreach (string skey in session.Keys)
                {
                    ht[skey] = session[skey];
                }

                byte[] _stable = CompactBinaryFormatter.ToByteBuffer(ht, module.CacheID);

                if (_table != null)
                {
                    if (BinaryComparer(_stable, _table))
                    {
                        return;
                    }
                }

                CacheItem sessionItem = new CacheItem(_stable);
                sessionItem.Priority = CacheItemPriority.NotRemovable;

                sessionItem.SlidingExpiration = TimeSpan.FromMinutes(session.Timeout);
                cache.Insert(sessionId, key.ToString(), sessionItem, false);
            }
            finally
            {
                if (session != null && strict)
                {
                    session.Clear();
                }
            }
        }
        public static void Clear()
        {
            HttpSessionState hss = HttpContext.Current.Session;

            if (hss != null)
            {
                hss.Clear();
            }
        }
Beispiel #12
0
        public static void logout(HttpSessionState session, System.Web.HttpResponse response)
        {
            string url = FormsAuthentication.LoginUrl;

            session.Clear();
            session.Abandon();
            FormsAuthentication.SignOut();
            response.Redirect(url, true);
        }
Beispiel #13
0
        public static void RemoveAll(HttpSessionState session) //Must be called where Session.Clear and Session.Abandon are called
        {
            var sessionGUID = LoggingHelper.GetSessionGUID(session);

            session.Clear();
            if (sessionGUID != null)
            {
                LoggingHelper.SetSessionGUID(session, sessionGUID.Value);
            }
        }
Beispiel #14
0
 public static void Logout(HttpSessionState Session)
 {
     if (Session != null)
     {
         Session.Clear();
         Session.Abandon();
         //DatabaseConnection dbConn = WebUtils.GetDatabaseConnection();
         //if (dbConn != null)
         //{
         //    WebUtils.SetSessionDatabaseConnection(Session, dbConn);
         //}
     }
 }
Beispiel #15
0
        public static int login(string username, string password, HttpSessionState s, string pDivID, int pForceLogin)
        {
            s.Clear();
            int    res = -1;
            string lDT = "";

            using (Uporabnik u = new Uporabnik())
            {
                res = u.login(username, password, pDivID, pForceLogin, out lDT);
                if (res == 0)
                {
                    u.setSession(s);
                }
            }
            return(res);
        }
Beispiel #16
0
        public static void Logout(HttpSessionState Session, HttpResponse Response = null)
        {
            IDatabaseConnector dbConnector     = new DatabaseConnectorClass();
            QueryParameter     logoutParameter = new QueryParameter();
            QueryResult        logoutResult    = new QueryResult();

            if (Session != null)
            {
                if (AppSession.GetSession("USER_ID", Session) != null)
                {
                    string userID = AppSession.GetSession("USER_ID", Session).ToString();

                    if (AppSession.GetSession("AUTHEN_TOKEN", Session) != null)
                    {
                        AuthenUtil.ClearToken(userID, AppSession.GetSession("AUTHEN_TOKEN", Session).ToString());
                    }

                    logoutParameter.Add("USER_ID", userID);
                    logoutResult         = dbConnector.ExecuteStoredProcedure("SYS_I_LOGOUT", logoutParameter);
                    logoutResult.Success = true;
                    logoutResult.Message = string.Empty;
                    logoutResult.RemoveOutputParam("error");
                }

                AppSession.SetSession("USER_ID", null, Session);
                AppSession.SetSession("AUTHEN_TOKEN", null, Session);
                AppSession.SetSession("IS_GUEST", true, Session);

                //ถ้าอยาก clear session จะต้องบังคับให้ client refresh หน้าเว็บด้วยนะ เพราะต้อง regen CSRF ด้วย
                Session.Clear();
                Session.Abandon();
            }

            if (Response != null)
            {
                HttpCookie authenTokenCookie = new HttpCookie("AUTHEN_TOKEN");
                authenTokenCookie.Value = "";
                Response.Cookies.Add(authenTokenCookie);

                //ถ้าอยาก clear session จะต้องบังคับให้ client refresh หน้าเว็บด้วยนะ เพราะต้อง regen CSRF ด้วย
                Response.Cookies["esrith.session.id"].Expires = DateTime.Now.AddDays(-30);

                Response.ClearContent();
                Response.ContentType = "application/json";
                Response.Write(logoutResult.ToJson());
            }
        }
Beispiel #17
0
    public static void LogoutStaffNotActivate()
    {
        HttpCookie objCookie = HttpContext.Current.Request.Cookies["SessionKey"];

        objCookie.Expires = DateTime.Now.ToThaiDateTime().AddDays(-1D);
        HttpContext.Current.Response.Cookies.Add(objCookie);

        HttpSessionState Hotels2Session = HttpContext.Current.Session;

        int intLogKey = int.Parse(HttpContext.Current.Request.Cookies["SessionKey"]["LogKey"]);

        UpdateSessionLogout(intLogKey);

        Hotels2Session.Clear();
        HttpContext.Current.Response.Redirect("~/admin/accessdenie.aspx?error=noactivate");
        HttpContext.Current.Response.End();
    }
Beispiel #18
0
    public static Model_Users SendEmailForgot(string email)
    {
        Model_Setting s = new Model_Setting();

        s = s.GetSetting();
        Model_Users user = GetUserbyEmailFront(email);


        if (user != null)
        {
            string body = string.Empty;
            string text = File.ReadAllText(HttpContext.Current.Server.MapPath("/Theme/emailtemplate/layoutforgot.html"), Encoding.UTF8);
            if (!string.IsNullOrEmpty(text))
            {
                string param       = user.UserID.ToString();
                string time        = DateTime.Now.ApiService_DateToTimestamp();
                string paramstring = param + "@" + time;

                HttpSessionState Hotels2Session = HttpContext.Current.Session;

                Hotels2Session.Clear();

                Hotels2Session.Timeout = 10;
                Hotels2Session[time]   = time;



                string path = ConfigurationManager.AppSettings["AuthorizeBaseURL"].ToString().Replace("/admin", "") + "ResetPassword?e=" + StringUtility.EncryptedData(paramstring);
                body = text.Replace("<!--##@Linkresetpassword##-->", path);
            }

            MailSenderOption option = new MailSenderOption
            {
                MailSetting = s,
                context     = HttpContext.Current,
                mailTo      = user.Email,
                Mailbody    = body,
                Subject     = "Forgot password and reset password"
            };
            MAilSender.SendMailEngine(option);
        }


        return(user);
    }
    // 会话退出
    public void sessionEnd(HttpSessionState session)
    {
        if (session["user"] == null)
        {
            return;
        }

        GMUser info = (GMUser)session["user"];

        lock (m_lockObj)
        {
            if (m_user.ContainsKey(info.m_user))
            {
                m_user.Remove(info.m_user);
                session.Clear();
            }
        }
    }
Beispiel #20
0
        public static void RestoreSessionFromCookie(this HttpSessionState Session)
        {
            try
            {
                SetSessionTypes();

                var coockieValue = EncryptHelpers.Desencriptar(CookieHelpers.GetValue(SessionKey._appBP));

                var dictSessionObject = new Dictionary <string, object>();
                dictSessionObject = JsonConvert.DeserializeObject <Dictionary <String, object> >(coockieValue);

                foreach (var item in dictSessionObject)
                {
                    if (item.Value != null)
                    {
                        var sessionKey = item.Key.ToEnum <SessionKey>();
                        if (sessionKey.Equals(SessionKey._appBP))
                        {
                            continue;
                        }
                        else if (sessionKey.Equals(SessionKey.Rol))
                        {
                            Set(Session, sessionKey, item.Value.ToString().ToEnum <AppRol>());
                        }
                        else if (lstCast.Any(x => x.Item1 == sessionKey))
                        {
                            var cast  = lstCast.FirstOrDefault(x => x.Item1 == sessionKey);
                            var value = JsonConvert.DeserializeObject(item.Value.ToString(), cast.Item2);
                            Set(Session, sessionKey, value);
                        }
                        else
                        {
                            Set(Session, sessionKey, item.Value);
                        }
                    }
                }
            }
            catch (Exception)
            {
                Session.Clear();
                CookieHelpers.DeleteAll();
            }
        }
        /// <summary>
        /// Fills NCache from the system ASP.NET session.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="session"></param>
        /// <param name="strict"></param>
        /// <param name="async"></param>
        void IDistributionStrategy.FillCacheFromSession(ISessionCache cache, HttpSessionState session, NSessionStateModule module, bool strict, bool isAbandoned)
        {
            if (cache == null)
            {
                return;
            }

            string     sessionId = session.SessionID;
            SessionKey key       = new SessionKey(sessionId, module.ApplicationId);

            try
            {
                if (session.Count == 0) //We need not to keep any empty session in the cache. [Asif Imam] April 09, 08 (This is incomplete. As it is never used. See Monolithic strategy for detail use-case)
                {
                    return;
                }

                cache.Remove(sessionId, key.ToString(), false);

                cache.Insert(sessionId, key.ToString(), DateTime.Now, Alachisoft.NCache.Runtime.Caching.ExpirationConstants.AbsoluteNoneExpiration, TimeSpan.FromMinutes(session.Timeout), CacheItemPriority.NotRemovable);


                string[] tempStrArr = new string[1];
                tempStrArr[0] = key.ToString();
                foreach (string skey in session.Keys)
                {
                    cache.Insert(sessionId, SessionKey.CompositeKey(sessionId, skey), session[skey], Alachisoft.NCache.Runtime.Caching.ExpirationConstants.AbsoluteNoneExpiration, Alachisoft.NCache.Runtime.Caching.ExpirationConstants.SlidingNoneExpiration, CacheItemPriority.NotRemovable);
                }



                if (strict)
                {
                    session.Clear();
                }
            }
            catch (Exception exc)
            {
                module.RaiseExceptions(exc, "SingleValueDistribution.FillCacheFromSession");
                //if (exceptionsEnabled) throw;
            }
        }
    public static ConjuntoDePermissoesUsuarioSistemas ObterConjuntoDePermissoesUsuario(HttpSessionState Session, string nomUsrRde = "", List <string> grupos = null)
    {
        ConjuntoDePermissoesUsuarioSistemas retorno = new ConjuntoDePermissoesUsuarioSistemas();

        //
        if ((!nomUsrRde.Equals(string.Empty)))
        {
            var bll = new ControleDeAcessoBLL();
            //
            retorno.InformacoesUsuario = bll.ObterInformacoesUsuario(0, nomUsrRde).FirstOrDefault();
            if (retorno.InformacoesUsuario != null)
            {
                retorno.SistemasPermitidos = bll.ObterSistemasPermitidos(CODSISINF, retorno.InformacoesUsuario.CODFNC);
                if (grupos != null)
                {
                    retorno.SistemasPermitidos = retorno.SistemasPermitidos.Where(x => grupos.Contains(x.DESGRPRDESISSMA)).ToList();
                }
            }
        }
        else if (Session["ConjuntoDePermissoesUsuario"] != null)
        {
            retorno = (ConjuntoDePermissoesUsuarioSistemas)Session["ConjuntoDePermissoesUsuario"];
        }
        //
        if (retorno != null && retorno.InformacoesUsuario != null && retorno.SistemasPermitidos.Count > 0)
        {
            Session["ConjuntoDePermissoesUsuario"] = retorno;
        }
        else
        {
            Session.Clear();
            Session.Abandon();
        }
        //
        return(retorno);
    }
 public void Clear()
 {
     _httpSessionState.Clear();
 }
Beispiel #24
0
 public void Dispose()
 {
     session.Clear();
     session.Abandon();
 }
Beispiel #25
0
 public void Clear()
 {
     _session.Clear();
 }
Beispiel #26
0
 public override void Logout(HttpSessionState session)
 {
     session.Clear();
 }
Beispiel #27
0
 public static void Logoff(HttpResponse Response, HttpSessionState Session)
 {
     Response.Cache.SetCacheability(HttpCacheability.NoCache);
     Session.Clear();
     FormsAuthentication.SignOut();
 }
 public void AbandonSession()
 {
     session.Clear();
     session.Abandon();
 }
Beispiel #29
0
 public void Clear()
 {
     Session.Clear();
 }
Beispiel #30
0
 public void ClearSession()
 {
     gSession.Clear();
 }
 public void Clear()
 {
     _sessionState.Clear();
 }
 public void ExitLogin()
 {
     Session.Clear();
 }