Help with visitor status and online time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
for3v3rforgott3n
Forum Newbie
Posts: 2
Joined: Tue Mar 10, 2009 9:22 pm

Help with visitor status and online time

Post by for3v3rforgott3n »

Hi everyone, I'm new here and I can't figure out how to do the following:
1. I'm trying to make add a line to my status section where it says Web Users Online: I'm not quite sure how to go about doing so and not sure what kind of info you guys need to help me so please tell me if you need any info =)
2. I'm also trying to keep a log (in my MySQL database) of the online time of the web users on the website and hopefully specific pages such as (for3v3rforgott3n logged in page x from Mar 08, 2009 18:32-19:43) or something of the sort =) Thank you for your time and I hope I will get to know you all better in the future!
sparrrow
Forum Commoner
Posts: 81
Joined: Mon Oct 20, 2008 12:22 pm

Re: Help with visitor status and online time

Post by sparrrow »

There are several ways to approach this, and there is already quite a bit of discussion across the internet about it; much of it right here in these forums. You could try a google or forum search for "whos online" or some variation thereof to locate the material.

To design a software solution to a business problem such as this, you should break it down into functional requirements. In other words, the specific things your code will need to do. I have tackled this one before, and here's my approach:
  • set time limit to pass before users become inactive
  • Set unique user identifier (IP address? session id? site login id?)
  • Delete inactive users from DB table
  • Pull all active users from DB table. Systematically check if current user is in this list, while dumping results into an array
  • If current user is active, update their last_activity_time in DB table
  • If user is not active, insert their record into DB table; Also insert into active users array
  • print count of online users with count() function, or print all array contents to display list of active users
for3v3rforgott3n
Forum Newbie
Posts: 2
Joined: Tue Mar 10, 2009 9:22 pm

Re: Help with visitor status and online time

Post by for3v3rforgott3n »

I already know how to do "Set unique user identifier (IP address? session id? site login id?)", am experimenting with the others but have not touched on "set time limit to pass before users become inactive" yet.
Post Reply