我程序聊天室,但无法找到显示在线和离线用户的方式。 我使用会话进行在线用户。当用户登录页面而不是空的会话更新数据库和联机1。 现在怎么知道用户从聊天或关闭浏览器注销。我知道whith会话时间或捕获可以做到这一点,但我不能写适合的代码。任何人都可以帮助我,并在这里完整的代码 感谢答案显示聊天室边栏中的在线用户
作秀在线:
session_start();
include("config.php");
connect();
$sql="SELECT `username` FROM `user` WHERE `online`=1";
$result=mysql_query($sql) or die (mysql_error());
if(mysql_num_rows($result)>0)
{
for ($i=0;$i<mysql_num_rows($result);$i++)
{
echo ('<b style="color:green;margin-left:10px;margin-top:10px;">'.mysql_result($result,$i,0).'</b><br>');
if($_SESSION['user']!=""
}
哪些是您使用实时通信技术? Websockets或ajax longpolling或不同的东西? – Christoph
我用阿贾克斯寻找在线用户和聊天 –