0

Why do i only see the status whether online or offline, another can not see it meaning that it can not, but i'm offline for others but for me i'm online ?

$time = time()+300;
$user = $_SESSION['logged'];
$query = mysql_query("UPDATE users SET status='$time' WHERE username='$user'") or die (mysql_error());
$query1 = mysql_query("SELECT * FROM users WHERE status >= '$time'") or die (mysql_error());
$timestamp = mysql_num_rows($query1);
if ($timestamp == 1) { $status = '<span><img src="images/online.gif"></span>'; } else { $status = '<span><img src="images/offline.gif"></span>'; }
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by breakforce
0

I am afraid this is a more complex issue. If the JavaScript event onunload or onbeforeunload worked than you could call by AJAX a script to let know your database that that user is no more online, but those events don’t really work always and I don’t believe that they ever will through security issues. What I do in most applications I need to know every second who is online is making a javascript function that is executing every x seconds generating an ajax call to the server saying that (I am the x user and I am still online). Of course that is not the best practice for performance.
Throught the last year I experimented with WebSockets and the result was great … but there isn’t yet a good practice for them in all browsers (not even major ones) while Chrome has its own implementation W3C has one other one that none one still fallows (and Firefox says that this is why it hasn’t yet embraced WebSockets)

0

For now i have not rolled yet to do with ajax, javascript, etc. simple php :), but as i explained my display only logged users can see my status and i want everyone to be able... :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.