in reply to Script Unload??

Browser issues are all client side. Unless you're running Perl Script, your CGI (making the assumption that that's what you're writing here) only sends data over a socket and prays that it gets there.

The timestamp idea is a pretty good one, though I'd do it a little differently. Just make a stack (an array) of users and their last message times. Hmm, you might want a hash too.

The hash stores the username as the key and a reference to an array. The first slot could be the datestamp. The second and third slots could be links to the previous and next arrays on the stack. You might put the username in another slot.

When a user submits a message, grab his little array through the hash, update the timestamp, and put it on the top of the stack. Every once in a while, check the item on the bottom of the stack. If it's older than X, remove it and say that the user has left the room.

Not too tricky. It's a whole lot nicer to do it in memory, as you're not dealing with much data here.