View Full Version : How can I get a list of userids of users online?
Chunky Monkey
10-16-2008, 09:03 AM
Hi,
Can somebody please tell me the easiest way to get a list of the userids of the users currently logged in?
Thank you.
VBDev
10-17-2008, 04:38 PM
Hi,
I think that the only way to achieve that will be to go through the session table with a bit of coding to get only the real online user (not those with session that is timeout).
Clément
Lynne
10-17-2008, 04:48 PM
Where do you want this list? Do you just mean you want to know the userids of the users when you look at the Who's Online list? If so, that can probably be achieved with just a template edit to add the userid next to their name.
Chunky Monkey
10-17-2008, 06:09 PM
Thanks for writing back, guys.
The list would be used to either exclude or include online users in various games, extras, etc., that I am adding to the forum. For instance, anyone logged in at any given time might be given a bonus this or that, or anyone offline might lose points in a game while anyone online might be "protected" from the event. I need an array of the online userids so I can add something to my database queries such as
foreach($offlineUsers as $user)
{
$sql .= " AND userid != '$user';
}
This way when I perform various operations on users and custom fields I've added for them in the user table I can exclude or include only those on or offline.
Any advice for how to get this array of online users would be greatly appreciated.
Thanks!
Lynne
10-17-2008, 06:52 PM
Take a look at the online.php script. It does a query to get the array (around line 245), so just steal the same query.
Chunky Monkey
10-17-2008, 08:06 PM
Easy enough, thanks so much for pointing me in the right direction!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.