jeboy Posted March 13, 2008 Share Posted March 13, 2008 Hi! I would like to ask if the following script I wrote is correct? It is placed at the top of the page. When a user logs in to the system, the username will insert to table logged_users (just for simplicity). What I'm trying to do is whenever a user get disconnected like for example he closes his browser, the script will automatically delete the user from the table logged_users. function clearLoggedUser() { if (connection_status() == 2) { $strSql = "DELETE FROM logged_users WHERE Username = '".$userName."'"; mysql_query($strSql); } } register_shutdown_function("clearLoggedUser"); Link to comment https://forums.phpfreaks.com/topic/95919-problem-with-connection_status-and-register_shutdown_function/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.