FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Browser Close User Offline





coreymanshack
How can you program it so that when the user closes the browser they are set to offline? I've looked for hours and can not find an answer.

Offline as in, updating a mysql row so when other people view their profile they are set to offline.

Or is there an easier way to do this I am overlooking.

No ajax please.
rvec
on every request set the user online for 5 min?
That's what most programs I know of do.

Add a column to the user table(or have a session table) and add the "last active" time (timestamp probably) and on every request update the value.

Then in a "now active" block on your website do a query like
Code:
$sql = "SELECT Username FROM User WHERE last_active<".($time-5*60);
coreymanshack
Thanks RVEC, this is what I came up with..

$currenttime = time();
$testtime = $currenttime - $lastactivity;
if( $testtime < 300 ) {
$template->replace("online", "Currently Online");
}else{$template->replace("online", "Currently Offline");}
Related topics
types of cell phones?
I Need Help For Intro Page On My Site
Co sadzicie o mojej stronie?
problem with my internet explorer
Problem index page
Why PHP
browser text size
which is better firefox or IE7?
Browser Version detection and redirection
Firefox v3 vs Internet Explorer 7 vs Opera 9
Browser close run a php script.
Mac OS X question
Help Me About Frih$
I'm still a noobie at home networks, please help...
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.