Right now I have my users online set so that whenever they actively click a link it will update their 'timelastactive' in the database. Then I see whos been active within the last 5 minutes, to determine whos online.
I am thinking about including a hidden iframe, including inside it a page to refresh every 30 seconds via javascript, to send a query to update their 'timelastactive' in the database. This would be a better way of guaging whos actually on the site.
This sounds good in theory, but would it actually work? And would all of those extra queries cause a system slowdown?
Users online
Moderator: General Moderators
Users online
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.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
personally, I'd do it with an image, if I wanted this functionality. Although any form of subrequest works. The problem will definitely be the server bogging down due to those update queries. From having the same sort of idea previously, the end result was just a pain. We had it set for three minutes between updates, but with 1100 users online at a time, that'd eat the server pretty quickly... and it did. All pages were affected because of the backlog in processing.. not a pretty sight.
Nasty
I once had a webcam in our LAN and FTP'd a picture from a it every 10 seconds.
So that It could appear on our class site. This was when I was in my 1st year of university,
My LAN account was then temporarily suspended because I was using up all the space on the server.
I was overwriting the picture, but the log file was becoming enourmous....
I was adding a line to the log for every FTP transaction.... How was i to know?!
So that It could appear on our class site. This was when I was in my 1st year of university,
My LAN account was then temporarily suspended because I was using up all the space on the server.
I was overwriting the picture, but the log file was becoming enourmous....
I was adding a line to the log for every FTP transaction.... How was i to know?!
Yeah, like feyd said, do it with an image. But if to help reduce the load, I'd do something like
You'll have to play some "games" with those two constants. If you have a site where people tend to be highly active -- that is they click lots of links, etc. You can have a rather low UPDATE_PERCENT, like 10, and a medium delay like 10 minutes. If the site is less active you'll need to raise one or both, etc
Code: Select all
// in your config file
define('UPDATE_PERCENT',15); // what percentage of hits to update lastvisited
define('ACTIVE_DELAY',15*60); // When is last active considered on-line
// in your wrapper around the image file
$randomNum = rand(0,100);
if ($randomNum < UPDATE_PERCENT) {
// update last visit timestamp in DB
}