English 中文(简体)
你们如何发现在菲律宾公共卫生和卫生局中为聊天口举行的不活跃的会议?
原标题:how do you detect an inactive session for a chat script in PHP?

这样一米书写类似于聊天器的东西,需要一种方法,在用户不再活跃时加以检测。 基本上需要让其他用户知道,如果用户X离开网页或关闭其浏览器,则该用户会 out。 除“在15个雷区里没有用户X的要求,因此可以推断出他”外,用服务器栏表示这一点的任何方法。

问题回答

正如他们在评论中所说的,你需要使用非洲宇宙航空研究开发机构。 (我认为)这样做最容易的方法是JQuery。

$(document).ready(function(){
    window.setInterval(function(){
        initiateSessionCheck();
    5000);

    function initiateSessionCheck() {
        $.ajax({
            type :  POST ,
            url :  sessioncheck.php ,
            success : function(data){
                //success
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                //error do something they are no longer active
            }
        });

    }
});

现在请各位发言。 php 要求你这样做。

session_start();

if (!$_SESSION) { //you could check a session variable explicitly like $_SESSION[ user_id ] !=   
    $return[ error ] = true;
} else {
    $return[ error ] = false;
}

echo json_encode($return);

它具有基本意义,但它应当做到!!





相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签