hi ,
at the bottom of the home page u can see that there are 34 guests.. and new registered users etc....
and users who are logged on.
can anyone help me by supplying the code for checking all the registered users!!
Problem::
i want to user the sessions functions to check whether a user is logged on or off...
i want to display all the registered users at the bottom of the page.. can anyone suggest me a way.
people have suggested me to user a database method..
but if the user closes his browser window without logging out.. then how??
bye
sessions [SOLVED]
Moderator: General Moderators
-
manjit.kool007
- Forum Newbie
- Posts: 4
- Joined: Mon Aug 27, 2007 10:04 am
sessions [SOLVED]
Last edited by manjit.kool007 on Wed Aug 29, 2007 10:52 am, edited 1 time in total.
You have a field in your users table that holds a timestamp. Each time a registered user views a page, you update this field with the current timestamp.
Then you can determine whos online or offline by querying to see who has been active within the last X minutes.. 5 minutes is a common setting (PHPBB uses a 5 minute window).
Then you can determine whos online or offline by querying to see who has been active within the last X minutes.. 5 minutes is a common setting (PHPBB uses a 5 minute window).
Code: Select all
$timeout = time()-300; //5 minutes
$onlineResult = mysql_query("SELECT `username` FROM `users` WHERE `user_last_visit` >= '$timeout'") or die(mysql_error());
if (mysql_num_rows($onlineResult))
{
echo '<p>Users Online</p>';
while ($onlineArray = mysql_fetch_assoc($onlineResult))
{
echo $onlineArray['username'] . '<br />';
}
}Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
-
manjit.kool007
- Forum Newbie
- Posts: 4
- Joined: Mon Aug 27, 2007 10:04 am
but
but then the mysql table will keep on increasing .....
Re: but
Why? There are no INSERTs, just UPDATEs ...manjit.kool007 wrote:but then the mysql table will keep on increasing .....
There are 10 types of people in this world, those who understand binary and those who don't
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
You may also want to look at XMLHttp tutorial (who's online example) which is held in the tutorials section.
non-registered who's online.
you could also check non-registered members, but then you need to set a cron job to clear the table every now and then.
Re: non-registered who's online.
Instead of a cronjob one may code it in the pages which users visit because it is not time critical issue.Dead_Ed wrote:you could also check non-registered members, but then you need to set a cron job to clear the table every now and then.
There are 10 types of people in this world, those who understand binary and those who don't
-
manjit.kool007
- Forum Newbie
- Posts: 4
- Joined: Mon Aug 27, 2007 10:04 am
done it
i have done it and it works very good enuf using the database.!!!thanq.. people!!!for u r time