public static Domain.User GetLoggedInUser(System.Web.HttpSessionStateBase session, string userName) { if (session[USER] == null) { LoadDataIntoSession(session, userName); } return(session[USER] as Domain.User); }
public static void AddOnce(this System.Web.HttpSessionStateBase session, string key, dynamic value) { if (!String.IsNullOrEmpty(key)) { if (session[key] == null) { session.Add(key, value); } } }
public static T GetValue <T>(this System.Web.HttpSessionStateBase sessionState, SessionKey sessionKey, T value) { if (sessionState[sessionKey.ToString()] != null) { return((T)sessionState[sessionKey.ToString()]); } else { return(value); } }
private static void LoadDataIntoSession(System.Web.HttpSessionStateBase session, string userName) { Repositories.UserRepository userRepo = new Repositories.UserRepository(); Domain.User loggedUser = userRepo.GetUserDetails(userName); if (loggedUser != null) { loggedUser.Roles.AddRange(userRepo.GetRolesAsArray(loggedUser.Username)); session[USER] = loggedUser; } }
public void CheckExceededMaxConcurrent(string username, System.Web.HttpSessionStateBase session) { if (!string.IsNullOrWhiteSpace(username)) { _userDataAccess = new UserDataAccess(_context); if (session["sessionid"] == null) { session["sessionid"] = "empty"; } // check to see if your ID in the Logins table has LoggedIn = true - if so, continue, otherwise, redirect to Login page. if (_userDataAccess.IsYourLoginStillTrue(username, (session["sessionid"] as string))) { // check to see if your user ID is being used elsewhere under a different session ID if (!_userDataAccess.IsUserLoggedOnElsewhere(username, (session["sessionid"] as string))) { // Do nothing } else { // if it is being used elsewhere, update all their Logins records to LoggedIn = false, except for your session ID _userDataAccess.LogEveryoneElseOut(username, (session["sessionid"] as string)); } } else { // Go to Login page session["sessionid"] = null; } } else { // Go to Logout page session["sessionid"] = null; session.Clear(); session.Abandon(); session.RemoveAll(); } }
public static object GetValue(this System.Web.HttpSessionStateBase session, SessionIndex sindex) { return(session[sindex.ToString()]); }
public static void SetValue(this System.Web.HttpSessionStateBase session, SessionIndex sindex, object value) { session[sindex.ToString()] = value; }
public static void SetValue(this System.Web.HttpSessionStateBase sessionState, SessionKey sessionKey, object value) { sessionState[sessionKey.ToString()] = value; }
public static bool SessionKeyExists(this System.Web.HttpSessionStateBase sessionState, SessionKey sessionKey) { return(sessionState[sessionKey.ToString()] != null); }
public static void RemoveValue(this System.Web.HttpSessionStateBase sessionState, SessionKey sessionKey) { sessionState.Remove(sessionKey.ToString()); }
public static T GetValue <T>(this System.Web.HttpSessionStateBase sessionState, SessionKey sessionKey) { return(GetValue <T>(sessionState, sessionKey, default(T))); }
public static void SetLoggedInUser(Domain.User user, System.Web.HttpSessionStateBase session) { session[USER] = user; }
public static void ReloadUser(System.Web.HttpSessionStateBase session, string userName) { LoadDataIntoSession(session, userName); }