如何在PHP中获得有关已关闭会话的通知

I am keeping a list of active users of my web site. When user logs in I add them to the list.

Then I periodically (on timer) call a PHP script which delays PHP session expiration time on the server each time by 10 mins.

When users logs out I remove them from the active users list. As timer is stopped and an expiration is not delayed anymore, a PHP session expires after 10 mins.

So far so good.

When user closes a browser without logging out, their session still expires after 10 mins as a time stamp is not updated anymore.

But this user still remains in my active users list !!

How can I remove this user?

I am keeping this list in order to prevent users from entering from 2 computers simultaneously, that is a client requirement.

EDIT: I am sure that this can be done as bank sites, ticket sites etc. somehow cope with this problem.

The simple answer is you can't. Not with PHP alone anyway. If you are happy to force javascript usage, you could write a script which would 'poll' the server from the user's browser on very regular intervals to let it know the user was still active.. you would then also reduce the interval set for your PHP script to keep things updated with more accuracy.

You could try updating the "active users" list on a more frequent basis, but it would generally make more sense to clear a user's session data upon each login. Therefore, if a second login occurs from another computer, the first one is terminated upon the next page load.