php:如何读取服务器上session变量的个数

来源:百度知道 编辑:UC知道 时间:2024/09/26 04:28:18
我想做一个在线人数统计的程序,不是说每个人登录后都会在服务器上产生一个session变量吗,这个变量在用户离开时就自动删除了不是吗?我也的确在用户登录时给每个人定义了一个session变量,我现在想通过读出服务器上所有session变量的个数来得到在线人数,该怎么写程序呀?谢谢大家!

<html>
<head>
<meta http-equiv="refresh" content="10; url=many.php">
</head>
<body>
<center>
<?
$time=gettimeofday(void);
$tmp=file("time.txt");
if ($tmp[0]=="")
{

$fopen0=fopen("time.txt","w+");
fputs($fopen0,$time[sec]);
fclose($fopen0);

$fopen1=fopen("ip.txt","w+");
fputs($fopen1,"");
fclose($fopen1);
}

$tmp1=file("time.txt");
$equal=($time[sec]-$tmp1[0]);
if ($equal>60)
{

$fopen0=fopen("time.txt","w+");
fputs($fopen0,"");
fclose($fopen0);
}

$fopen=fopen("ip.tx