I have a password protected website with PHP sessions. How do I show how many people are logged in at the moment?
I have the users last logged in time saved in a database. I could even create a new field for last page visit and update that each time the user visits the next page. First I was thinking showing users as online if their last page visit is no older than five minutes. However that user could log out a second after his/her last page visit, or stay logged in but not refresh or move from a page for hours...
How can it be done?
users online
Moderator: General Moderators
Re: users online
That's how it's done.speedy33417 wrote:I could even create a new field for last page visit and update that each time the user visits the next page.
You'll just have to live with them logging out before 5 minutes is up. 5 minutes is still an accurate representation of who is online. This forum determines who is online by using a 5 minute timeout.speedy33417 wrote:First I was thinking showing users as online if their last page visit is no older than five minutes. However that user could log out a second after his/her last page visit, or stay logged in but not refresh or move from a page for hours...
As far as the hours thing, if your script checks whos been active in the last 5 minutes, then it doesn't matter if someone idles.. they will be shown as logged out.
If you want a truly accurate representation (including when they logout, and who is idle but still online), then you could have a transparent image, or even a hidden frame that sends a query to update their timestamp in the db every X seconds.
The latter method is not preferred due to excessive amounts of queries being sent.
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.
- speedy33417
- Forum Contributor
- Posts: 128
- Joined: Sun Jul 23, 2006 1:14 pm