Jump to content

remove user from table when browser window is closed


web_master

Recommended Posts

Hi,

 

I got online users - when somebody go online, his NAME goes to "chat_online" table, and than see it in query.

 

I got in browser cookies:

 

name

password

session

 

How can I remove (delete) online user from "chat_online" table when he close the browser window?

 

 

"chat_online" table have:

 

chat_online_id

chat_online_user

chat_online_session

 

rows.

 

When somebody goes online his username and session goes in the table.

 

 

<?php
//Query return from dbase
$query_return = mysql_query("SELECT DISTINCT `chat_online_user` FROM `chat_online` ORDER BY `chat_online_user` ASC");

	if(!$query_return) {
		print mysql_error();
		exit;
	}

while($request = mysql_fetch_array($query_return)) {

	print "<p class=\"TXT_USER_ADMIN\">".$request['chat_online_user']."</p>";

}
?>

You'd have to have a new table. Everytime the user performs an action update the table.

Then have a cron run every 2-3 minutes and check if their has been any activity in the last X minutes from the users. If there hasnt, then delete their name from the chat_online table.

You'd have to have a new table. Everytime the user performs an action update the table.

Then have a cron run every 2-3 minutes and check if their has been any activity in the last X minutes from the users. If there hasnt, then delete their name from the chat_online table.

 

 

I see, I think I must to find other way to do that - Ajax or other - because maybe the user will be there few hours without to want to say something.

 

Where can I find something about - ajax - the other way to do that?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.