Basically I have a chat, using AJAX, PHP.

I let guests login by filling their name and clicking login.
It fills the session `$_SESSION['guest']`.

Now, when they close their browsers, or something, once the session ends, I want it to say in the chat

"The username has left the chat".

But I am not sure on how would I do this.
Any ways to do it? Maybe I could fill an array of users that were active in the past 5 minutes, if not, remove from the array and it will kick them off the chat.

Any ideas?