Jump to content

Problem with connection_status() and register_shutdown_function()


jeboy

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.