FredFrothen Posted March 5, 2011 Share Posted March 5, 2011 Hey, guys. I'm a programmer and i've designed an application to assist in an online game. When users visit my website for whatever reason i want to display the amount of users currently using my application. As you may have guessed i'm not to crash hot at php or any web related languages at that . What i think will work, is when my application starts up, i can make it visit a webpage in the background and just idle there while they are using the program, when they close the program obviously it is no longer viewing that webpage. So if there some sort of php counter i can make for this? I was reading some sources to php counters and they count the amount of "sessions" and display that, i was just curious if my program navigates to a webpage upon opening and it doesn't do anything will this 'time it out'? Anyway, any help is appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
FredFrothen Posted March 7, 2011 Author Share Posted March 7, 2011 or at least give me tips on how to do it? Quote Link to comment Share on other sites More sharing options...
cliftonbazaar Posted March 7, 2011 Share Posted March 7, 2011 The way I do it is in the database there is a field which is updated with the time a player last loaded a page, then when any player goes to a page the database does a quick count of everyone who has loaded a page in the last five minutes. Crude but it works for me. Quote Link to comment Share on other sites More sharing options...
FredFrothen Posted March 7, 2011 Author Share Posted March 7, 2011 so if the user is inactive after 5 mins their user count drops out? Quote Link to comment Share on other sites More sharing options...
cliftonbazaar Posted March 7, 2011 Share Posted March 7, 2011 For my purposes 5 minutes is fine. As I said before, this is a crude method but it suits my situation. Quote Link to comment Share on other sites More sharing options...
n3r0x Posted March 7, 2011 Share Posted March 7, 2011 Something like cliftonbazaar said works i would however make a table for tracking online users, since it would be faster and more searching a smaller table for users online in the last 5 or 10min. Basicly a 2 or 3 field table with userid or IP (userid if you only plan to track logged in users, IP if you plan to track both logged in and visitors) and last_access A third column could be tiny int to is_logged_in either 1 or 0 Then again i like having separate tables for stuff like this. Quote Link to comment 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.