mlse
05-06-2005, 12:57 PM
Hi,
I am using the session control stuff provided by PHP, which is all well and good. I have implemented a simple mechanism whereby when the user logs on, I record their status as ONLINE in my MySQL database. Conversely, when they log off (by clicking the "log off" button on the mnavigation menu on any web page in the site), i destroy the session and record their status as OFFLINE in the database. When they close all browser windows related to the site, PHP takes care of destroying the session, however I don't know an easy way of recording their status as OFFLINE in the database.
The only way I can think of to do this is to have a timeout associated with the session (which will automatically set their status to OFFLINE after, say, 30 minutes of inactivity), and/or I could have an instance-count which starts at 1 and is incremented each time a browser window is opened that is associated the session, then force a closure notification to be sent to the server upon closure of the browser window, which causes the inctence-count to be decremented, and sets their status to OFFLINE when the instance-count reaches zero. This, however, does not cater for Alt-F4 window closure, nor does it cater for explicit process kill via the process control window (in the OS), nor does it cater for the web browser moving off a page within the site.
Does anyone have any bright PHP-related ideas around this subject?
TIA,
Mike.
I am using the session control stuff provided by PHP, which is all well and good. I have implemented a simple mechanism whereby when the user logs on, I record their status as ONLINE in my MySQL database. Conversely, when they log off (by clicking the "log off" button on the mnavigation menu on any web page in the site), i destroy the session and record their status as OFFLINE in the database. When they close all browser windows related to the site, PHP takes care of destroying the session, however I don't know an easy way of recording their status as OFFLINE in the database.
The only way I can think of to do this is to have a timeout associated with the session (which will automatically set their status to OFFLINE after, say, 30 minutes of inactivity), and/or I could have an instance-count which starts at 1 and is incremented each time a browser window is opened that is associated the session, then force a closure notification to be sent to the server upon closure of the browser window, which causes the inctence-count to be decremented, and sets their status to OFFLINE when the instance-count reaches zero. This, however, does not cater for Alt-F4 window closure, nor does it cater for explicit process kill via the process control window (in the OS), nor does it cater for the web browser moving off a page within the site.
Does anyone have any bright PHP-related ideas around this subject?
TIA,
Mike.