setcookie()本身带有时效.
如果检查当前新闻的cookie存在,就不执行update操作,这本身没有什么难度呀?

解决方案 »

  1.   

    楼主看一下PHP手册不就知道了。Cookies有过期机制的嘛。bool setcookie  ( string $name  [, string $value  [, int $expire  [, string $path  [, string $domain  [, bool $secure  [, bool $httponly  ]]]]]] )第三个参数就是设置过期时间的。
      

  2.   

    我这么写的
    setcookie("count",$id."$".getenv('REMOTE_ADDR'));if ($_COOKIE["pcount"]!=$id."$".getenv('REMOTE_ADDR'))
    {
    mysql_db_query($dbname,"update news set times=times+1 where id=$id");
    }好像无效啊
      

  3.   

    我这么写的 
    setcookie("count",$id."$".getenv('REMOTE_ADDR')); if ($_COOKIE["count"]!=$id."$".getenv('REMOTE_ADDR')) 

    mysql_db_query($dbname,"update news set times=times+1 where id=$id"); 
    } 好像无效啊
      

  4.   

    第三个参数是设置过期时间的,比如setcookie("username",$username,time()+1*24*60*60,"/");到底想实现什么效果?说来听听
      

  5.   

    就是防刷新计数器
    mysql里面每个记录对应一个timemysql_db_query($dbname,"update news set times=times+1 where id=$id");