Thanks Shabbir for your reply.
I researched some more about sessions and found out about session id. I got the idea.
I am trying to make a chat script using php, ajax and mysql. If I use sessions for storing information how will I show who's online in a chat room? Is there a way to display all active sessions.
Another way is storing online users' information in database. I can keep a logout button which would remove the user's record from database, but if the user closes the browser instead of logout button, then the record wont be deleted from table and he won't be able to log in again.
Help me find a solution.