Tuesday, June 17, 2014

Common Session methods Use By Creating separate class

 //added by shekhar 13/6/2014 To Clear Current Session
        public void ClearSession()
        {
            HttpContext.Current.Session.Clear();
        }
        //End Of Clear Session
        //added by shekhar 13/6/2014 To Remove item in session
        public void RemoveFromSession(string key)
        {
            HttpContext.Current.Session.Remove(key);
        }
        //end Of remove  

        public void SetInSession(string key, object value)
        {
            if (HttpContext.Current == null || HttpContext.Current.Session == null)
            {
                return;
            }
            HttpContext.Current.Session[key] = value;
        }

        public object GetFromSession(string key)
        {
            if (HttpContext.Current == null || HttpContext.Current.Session == null)
            {
                return null;
            }
            return HttpContext.Current.Session[key];
        }

        public void UpdateInSession(string key, object value)
        {
            HttpContext.Current.Session[key] = value;
        }

No comments:

Post a Comment