I see what you mean now.
Off the top of my head I think a better approach would be this:
- user logs in, his name and a timestamp are added to the list of active users
- every time a user accesses a page on your list his timestamp is updated to the current timestamp.
- when a user logs out you remove him from the file
- for the chat program, when looking for who is logged in you pick form the list all the people who's timestamp is less than, let's say, 10 minutes old and delete the rest.
The best way to do this of course would be to use a database instead of a text file though :)
Jean-Christian Imbeault
Matt Palermo wrote: > I am doing this, because I am making a text file with a list of all > existing sessions. Then another page checks to see if all of these are > still active and exist, and if not it will take action and remove the > session id from the list. It goes along with the question I asked > earlier about the Flash chat program. I figured that I would make a log > file of all sessions when a user logs in to chat, then if the user > doesn't log out properly (with the log out button) and just closes the > browser or shuts off the computer, then their id will be removed from > the list, since the session doesn't exist anymore. If there is an > easier way to accomplish this, then please fill me in. Here is the > Flash chat question I asked earlier with more details for you: > > "Hey, I need some advice if anyone is willing to offer it. I have a > chat program I am working on. The interface is built in flash, and it > uses PHP also. There is a main chat area where the users type their > messages back and forth, and there is also a smaller area which displays > all of the currently logged-in users. When a user logs into the chat > room, it adds their nickname to a users.txt file, which creates a list > of all the online users and is then displayed in the chat page. I also > have a logoff button that will search for the users nickname in the > users.txt file and remove it, so that it won't be displayed in the chat > window anymore. The only problem I am having is that if a user doesn't > click on the logoff button and instead just closes the internet window > or shuts off their computer, then their nickname will still appear in > the list of users, since it wouldn't get a chance to be removed by the > logoff button. I'm not sure how to accomplish this, I would appreciate > any help you can offer me. Thanks a lot." > > Thanks. > > Matt
--
Jean-Christian Imbeault
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php