Jump to content

Would anyone be able to help me make a 'User's online counter'.


FredFrothen

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.