用户有动作就把时间记录进数据库,
5分钟没动作自动update为退出!

解决方案 »

  1.   

    使用session
    if(time()-$_SESSION['time']>60*5){
       session_destory();
    }else{
      $_SESSION['time'] = time();
    }
    其中$_SESSION['time']是在登陆成功时设置的时间。
      

  2.   

    网页中用一个定时器,网页加载后计时,鼠标在网页上移动时会产生以下事件:
    document.onmousemove
    在该事件中定时器清空。否则累计到5分钟后关闭。
      

  3.   

    <script language="JavaScript"><!--
    var meizz; //设置一个全局变量
    var n = 300 * 1000; //时间设置(300秒)
    meizz = setTimeout("window.location.href='www.htm'", n);
    function autoJump()
    {
      clearTimeout(meizz);
      meizz = setTimeout("window.location.href='www.htm'", n);
    }document.attachEvent("onmousemove", autoJump);  //addEventListener
    document.attachEvent("onkeydown", autoJump);
    //--></script>
      

  4.   

    这个肯定要用js了。php不能判断你的鼠标和键盘是否有动作这类事件。