budimir Posted July 22, 2008 Share Posted July 22, 2008 Hey Guys, Does anyone have an idea, how could I display how many users is connected to a mysql database? All of them who are runing queries on the database. Quote Link to comment https://forums.phpfreaks.com/topic/116018-solved-displaying-users-connected-to-mysql/ Share on other sites More sharing options...
turkman Posted July 22, 2008 Share Posted July 22, 2008 If you create your own user table, then when they log in update their id in the table to say logged in when they log out get it to change to logged out. Then to see who is online "SELECT * FROM userstable where onlinestatus = 'logged in';" Is this what you mean? Quote Link to comment https://forums.phpfreaks.com/topic/116018-solved-displaying-users-connected-to-mysql/#findComment-596612 Share on other sites More sharing options...
waynew Posted July 22, 2008 Share Posted July 22, 2008 If access to the db is controlled via the application, you could do as Turk said. Quote Link to comment https://forums.phpfreaks.com/topic/116018-solved-displaying-users-connected-to-mysql/#findComment-596614 Share on other sites More sharing options...
JonnyThunder Posted July 22, 2008 Share Posted July 22, 2008 As far as I know, unless you use persistent DB connections nobody will be connected to your mysql database (except when a query takes place). If you're talking about sessions, then what I do is store the users session ID in a table and use session_set_save_handler to redirect session control to the database. That way you can query the table to see how many sessions are active, based on last activity. Quote Link to comment https://forums.phpfreaks.com/topic/116018-solved-displaying-users-connected-to-mysql/#findComment-596641 Share on other sites More sharing options...
budimir Posted July 22, 2008 Author Share Posted July 22, 2008 OK, It's now what I was actually looking for, but I did get an idea. Thanks, guys. Quote Link to comment https://forums.phpfreaks.com/topic/116018-solved-displaying-users-connected-to-mysql/#findComment-596659 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.