Hi,
Whats the best way to echo (display the user names) an accurate reading of the user names that are logged in?
Thanks
Display logged in members
Moderator: General Moderators
Hey,
This code below .. below suits my user database .. It seems to echo all users rather than only users that have been active for less that 5 minutes?
Thanks
This code below .. below suits my user database .. It seems to echo all users rather than only users that have been active for less that 5 minutes?
Code: Select all
$time = time();
$timeonline = '300';
$timedifference = time() - $timeonline;
$whosonline = mysql_query("SELECT * FROM users WHERE last_login >= '$timedifference'");
while($whosonlinearray = mysql_fetch_array($whosonline)){
echo $whosonlinearray['alias'];
}Hi,
Im using now() to insert with date/time as setting .. Your code works great thanks ..
Another question with sessions .. When people logout things work fine .. but when they just close the browser the session stays active for like 5 minutes .. giving false readings of whos online etc etc .. Can anything be done so when the browser is closed .. the session is destroyed at the same time? How are things done witihn the likes of devnetworks forum etc .. or is the session timout the best answer ..?
Cheers
Im using now() to insert with date/time as setting .. Your code works great thanks ..
Another question with sessions .. When people logout things work fine .. but when they just close the browser the session stays active for like 5 minutes .. giving false readings of whos online etc etc .. Can anything be done so when the browser is closed .. the session is destroyed at the same time? How are things done witihn the likes of devnetworks forum etc .. or is the session timout the best answer ..?
Cheers
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
the timeout is what kills the session if they don't log out. It works just fine.. There's almost no way to know definitively who is looking at a particular page from second to second, because that request is the only live connection you will typically have. Unless you are using a realtime media connection, there is little way to know all the time.
These things are a basic snapshot of who has been active in the last x minutes, nothing more.
These things are a basic snapshot of who has been active in the last x minutes, nothing more.