Jump to content


User tracking and management

  • Please log in to reply
2 replies to this topic

#1 majocmatt

  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 17 April 2006 - 03:07 PM

How does a site like phpfreaks track the members to see when they are online? I notice when I scroll down to the bottom it says 'recently active members' then it says in the last 15 minutes.. So that gives me the indication that it checks for page requests every 15 minutes, or somewhere in between?

I ask because with the cookie always-keep-me-logged-in thing, I can't really figure out how to do that since the users won't have to pass thru a login processor. Is there a database storing this information and like a cron deleting them every few minutes?

I'm just curious if someone could clear this up for me, just how user tracking works with the 'remember me' option on, and user does not have to physically login everytime, yet it knows when they are online.


#2 trq

  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 April 2006 - 03:32 PM

I assume they would be using some sort of custom session object. Using the [a href=\"http://au3.php.net/manual/en/function.session-set-save-handler.php\" target=\"_blank\"]session_set_save_handler[/a] function you are able to store server side sessions in a database instead of flat files. This enables you to run queries over all session variables in use. With this in place, its pretty easy to write a simple script that adds your current page to the session variables. eg;
$_SESSION['current_page'] = $_SERVER['PHP_SELF'];
Then run a simple query to get a list of all users on the current page.
$sql = "SELECT username FROM sessions WHERE current_page = {$_SERVER['PHP_SELF']}";
Ive built a few of these custom sessions handlers and they really do make things like who's online scripts really easy.

As for not having to pysically login and yet be remembered, thats as simple as saving a cookie.

#3 majocmatt

  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 17 April 2006 - 05:52 PM

does anyone have a good reference tutorial for this type of thing? most stuff i find isn't counting on the fact that i have setup a cookie for an automatic login. the ones i find only do this stuff for passing thru a login processor.

if anyone has links to tutorials for stuff like what's new, who's online, etc that'd be great

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users