// Get DataSet of on-line users DataSet users = SessionManager.GetOnlineUsers(where, orderBy, topN, location, siteName, includeHidden, includeKicked);
if (!DataHelper.DataSourceIsEmpty(users)) { foreach (DataRow userDr in users.Tables[0].Rows) { // Create object from DataRow UserInfo modifyUser = newUserInfo(userDr); // Update the properties modifyUser.FullName = modifyUser.FullName.ToUpper(); // Save the changes UserInfoProvider.SetUserInfo(modifyUser); } returntrue; } returnfalse; }
The following example checks if a specified user is currently on-line.
privatebool IsUserOnline() { bool includeHidden = true; // Get user and site objects UserInfo user = UserInfoProvider.GetUserInfo(CMSContext.CurrentUser.UserID); SiteInfo site = SiteInfoProvider.GetSiteInfo(CMSContext.CurrentSiteName); if ((user != null) && (site != null)) {
// Check if user is on-line returnSessionManager.IsUserOnline(site.SiteName, user.UserID, includeHidden);
} returnfalse; }
The following example kicks a user from a site.
privatebool KickUser() {
// Get the user UserInfo kickedUser = UserInfoProvider.GetUserInfo(CMSContext.CurrentUser.UserID);
if (kickedUser != null) { // Kick the user SessionManager.KickUser(kickedUser.UserID); returntrue; } returnfalse; }