I’ve been trying to figure out exactly what the active_users table is for. Apparently it keeps a record of all users both web and manager from the first time they log in. Some of the fields I can understand what they are, but the id field I can’t figure out. Also, all web users apparently get an action of 998 no matter what they are doing. It seems to me that there could be an update to set action to 8 (indicating log out) when a web user logs out, even though it really doesn’t matter, but then the reporting scripts will report a log out status.
What I don’t quite understand is why these records don’t get cleared out after a certain length of time. I even found a couple of web users that I had deleted, then re-created much later, still there.
Does anyone else feel that a bit more responsive logging of web users might be useful? I know there is a timestamp so last activity can be determined, but that still doesn’t give any clue as to the actual current status of the web user.
OK, I figured out that the id field is the document id the user is currently on. So the only thing left is to change the web user’s action to indicate a logout, and since 8 is already used for manager users and won’t conflict with the document id, I would like to propose simply adding a line to the weblogin.processor.inc.php file immediately before clearing the session, around line 131:
// update status in active_users table
$modx->db->update("action = 8",$modx->getFullTableName('active_users'),"internalKey = -".$_SESSION['webInternalKey']);