使用session我现在用的
session_start();
if(!isset($_SESSION['counter']))  {  
   $_SESSION['counter']  =  1;  
 
  $file  =    "counter.txt  ";  
//File  name  
 
//That's  it  
 
if(!file_exists("$file")){  
touch("$file");  
chmod("$file",0777);  
$fp=fopen("$file","r+");  
fseek($fp,0);  
$compteur  =  0;  
fputs($fp,$compteur);  
}  
 
if(  is_readable("$file")  and  is_writable("$file")){  
 
$fp=fopen("$file","r+");  
$compteur=fgets($fp,9999);  
fseek($fp,0);  
$compteur++;  
fputs($fp,$compteur);  
fclose($fp);  
print  $compteur;  
}  else  {  
chmod("$file",0777);  
}