majocmatt Posted April 17, 2006 Share Posted April 17, 2006 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. Quote Link to comment Share on other sites More sharing options...
trq Posted April 17, 2006 Share Posted April 17, 2006 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. Quote Link to comment Share on other sites More sharing options...
majocmatt Posted April 17, 2006 Author Share Posted April 17, 2006 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.