Ok, I'm drawing a complete blank on this one. This is, or should be, a very simple task. For some reason I'm lost for a solution. Here's the deal:
I'm working on a site that requires members to login, etc. I am using sessions to track users and maintain data. I want to display the usernames of those who are logged in at the current time. I'm just coming up empty right now. The best solution I can think of is to drop each users name into a MySql table of users who are online. That way I could just poll the table to generate my list of who is online. Easy enough. I can just drop them from the "online" table when they log off. The problem is that the majority of users don't log off. Instead they go on to other things or shut down entirely and the session expiration logs them off. That means I would either need that expiration to trigger a script that drops the user from the "online" table or I need some other method.
I'm not great with triggers, so I would appreciate anything you can offer on that one. The only other possibility is to add a timestamp to the "online" table that is updated every time a user access a page. That way I could, in theory, add a process to the script that polls the table that would drop any names who haven't done anything for X number of minutes. File that under crude, but effective. I know there's a better way. Someone please point me in the right direction.
I'm working on a site that requires members to login, etc. I am using sessions to track users and maintain data. I want to display the usernames of those who are logged in at the current time. I'm just coming up empty right now. The best solution I can think of is to drop each users name into a MySql table of users who are online. That way I could just poll the table to generate my list of who is online. Easy enough. I can just drop them from the "online" table when they log off. The problem is that the majority of users don't log off. Instead they go on to other things or shut down entirely and the session expiration logs them off. That means I would either need that expiration to trigger a script that drops the user from the "online" table or I need some other method.
I'm not great with triggers, so I would appreciate anything you can offer on that one. The only other possibility is to add a timestamp to the "online" table that is updated every time a user access a page. That way I could, in theory, add a process to the script that polls the table that would drop any names who haven't done anything for X number of minutes. File that under crude, but effective. I know there's a better way. Someone please point me in the right direction.