既然用了文件来保存,又何必再用session呢?
<body>
<?
  $ip=getenv("REMOTE_ADDR");
  echo $REMOTE_ADDR.":".$REMOTE_PORT." ";
  $filec="userscount.txt";
  $fileinfo="iptime.txt";
  if(file_exists($filec))
  {
    $arr=file($filec);
    $count=(int)$arr[0];
  }
  else
    $count=0;
  $fp=fopen($filec,"w");
  fputs($fp,++$count);  
  fclose($fp);
  echo "You are the $count guest.<br>";  $timestr=date("Y-m-d D H:i:s");
  echo("You visit here at $timestr.<br>");
  $fp=fopen($fileinfo,"a");
  fwrite($fp,$REMOTE_ADDR.":".$REMOTE_PORT."@".$timestr."\n");
  fclose($fp);
?>
</body>  上述代码要对$REMOTE_*的获得进行一些修改,因为PHP4.2.*以后的版本对这些变量有改动。