Handling sessions in Flash.
If you have read my previous post you will know what I'm talking about. I wanted to make a chat with Flash and PHP will handle the communication with the database. The problem I faced with was knowing when a user leaves the chat and so it will be erased from the "online users" list and from the database, like in a forum. I asked Jonas
about it and explained me that in forums PHP handles the sessions.
Well, I began to dig through the PHP files used in the phpBB forums
and found a file called "sessions.php". There I learn how PHP knows when a user is on-line or not. There was the solution. PHP only stores the time when the user logged and then checks when that script is called if that time plus the "session_timeout" time has come. If the user reach that time is droped from the online users table and the online users list is refresh.
Then an idea struck me. All this session handling can be achive in Flash!! We can store the time the user logged in with the getTime method of the Date object. Then when the user post a message or after some seconds we can retrieve that data and compare it so we can decide if the user has being timed out.
I will develop a script for handling sessions and post it as soon as I have it finish. Forgive my English if I made some grammar mistakes but I hope you understand the main point. I'm still learning the language.