Jump to content

Archived

This topic is now archived and is closed to further replies.

majocmatt

User tracking and management

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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.