Jump to content

Showing the list of online users when programming an online chat room...........


raza.shahzad

Recommended Posts

I started to work out an online chat room using PHP. the basic idea was to use PHP wity MySQl to provide the users with a good online web browser based chat experience. In doing so i caught myself up in a problem that i want to discuss with you guys.
Displaying the list of online users is not a big issue with PHP. The 'behind the scene' structure is like....
1. the user logs in to the website with his username and password. everything is as simple as it can be. and there can be many other ways for doing so. i will appreciate help in any direction.
2. the database contains a column that saves the status of the user say:
name=status
value=online or offline.
if the user is online the status is set to the same and for offline the status in the database is saved or changed/updated to offline.
as long as the user uses the website/chat his name appears to be online and as he/she clicks log off, his status is set back to offline. and so on.
the problem comes when the user disconnects without clicking the log off link. in this case i am unable to set the database entry of status to offline because the user leaves the chat, turns off his browser or shuts down his PC without clicking the log off button due to which the process remains incomplete and other users who are online see the person to be online too.
Simply speaking, i want to know a better way to implement to my chat website. i wish the solution be like yahoo or msn messengers. whenever a user logs off or shuts down his PC accidently, the other user recieves a message that MR.XYZ has logged off.
Is there any solution to this problem. definitely there are many. the one i am thinking of is to place a field in the database that stores the time the last msg was recieved from the user and if the time extends a particular period, say 15minutes, the script considers the user to be offline. but this one is not the same as i want it to be like yahoo messengers'.
Link to comment
Share on other sites

  • 1 month later...
[quote author=raza.shahzad link=topic=101857.msg403538#msg403538 date=1153872169]
I started to work out an online chat room using PHP. the basic idea was to use PHP wity MySQl to provide the users with a good online web browser based chat experience. In doing so i caught myself up in a problem that i want to discuss with you guys.
Displaying the list of online users is not a big issue with PHP. The 'behind the scene' structure is like....
1. the user logs in to the website with his username and password. everything is as simple as it can be. and there can be many other ways for doing so. i will appreciate help in any direction.
2. the database contains a column that saves the status of the user say:
name=status
value=online or offline.
if the user is online the status is set to the same and for offline the status in the database is saved or changed/updated to offline.
as long as the user uses the website/chat his name appears to be online and as he/she clicks log off, his status is set back to offline. and so on.
the problem comes when the user disconnects without clicking the log off link. in this case i am unable to set the database entry of status to offline because the user leaves the chat, turns off his browser or shuts down his PC without clicking the log off button due to which the process remains incomplete and other users who are online see the person to be online too.
Simply speaking, i want to know a better way to implement to my chat website. i wish the solution be like yahoo or msn messengers. whenever a user logs off or shuts down his PC accidently, the other user recieves a message that MR.XYZ has logged off.
Is there any solution to this problem. definitely there are many. the one i am thinking of is to place a field in the database that stores the time the last msg was recieved from the user and if the time extends a particular period, say 15minutes, the script considers the user to be offline. but this one is not the same as i want it to be like yahoo messengers'.
[/quote]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.