Jump to content

User tracking and management


majocmatt

Recommended Posts

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.

thanks.
Link to comment
Share on other sites

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 [b]all[/b] 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;
[code]
$_SESSION['current_page'] = $_SERVER['PHP_SELF'];
[/code]
Then run a simple query to get a list of all users on the current page.
[code]
$sql = "SELECT username FROM sessions WHERE current_page = {$_SERVER['PHP_SELF']}";
[/code]
Ive built a few of these custom sessions handlers and they really do make things like [i]who's online[/i] scripts really easy.

As for not having to pysically login and yet be remembered, thats as simple as saving a cookie.
Link to comment
Share on other sites

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 [i]what's new[/i], [i]who's online[/i], etc that'd be great
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.