Update Session Value

Sor keneth

New Member
I have creating an session at the time of login, in that Session I have put the user object.\[code\]public sealed class MyContext{ [ThreadStatic] private static MyContext staticContext = null; public HttpContext Context { get { return HttpContext.Current; } } private MyContext() { } public static MyContext Current { get { MyContext myContext = null; HttpContext context = HttpContext.Current; if (context != null) { //it in the Items collection (a per request store) if (context.Items.Contains("CONTEXT_KEY")) myContext = context.Items["CONTEXT_KEY"] as MyContext; else { myContext = new MyContext(); myContext.Context.Items["CONTEXT_KEY"] = myContext; } } else if (staticContext != null) { myContext = staticContext; } else { //create a new instance of static context as there is no web request staticContext = new MyContext(); myContext = staticContext; } return myContext; } } public MyUser User { get { MyUser user = null; if (Current.Context.Session["LoggedInUser"] != null) user = (MyUser)Current.Context.Session["LoggedInUser"]; else { user = UserDetail.GetUser(HttpContext.Current.User.Identity.Name); if (user == null) { //if there is no userID, create anonymous user user = new MyUser(); user.IsAnonymous = true; user.UserID = 0; } //cache in session Current.Context.Session["User"] = user; } return user; } set { Current.Context.Session["User"] = value; } }}//end class\[/code\]Now I am using this Context in whole application, I am facing problem in one case if user is login and same time admin Deactivate that user, I can't stop the user activity, this is because user's information is in session.So please suggest me how to update that particular user's information when admin deactivate that user.
 
Back
Top