php 如何获取所有的 sessionid ?或获取所有的session
就是想通过一个.php文件读取所有的 sessionid ?或获取所有的session ??
class Session {<br> private static $handler=null;<br> private static $ip=null;<br> private static $lifetime=null;<br> private static $time=null;<br> //初始化变量;<br> private static function init($handler){<br> self::$handler=$handler;<br> //$_SERVER["REMOTE_ADDR"]获取客户端路由地址;<br> self::$ip = !empty($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : 'unknown';<br> //ini_get()获取配置文件变量;<br> self::$lifetime=ini_get('session.gc_maxlifetime');<br> self::$time=time();<br> }<br> <br> static function start(PDO $pdo){<br> self::init($pdo);<br> //_CLASS_ 代表本类;<br> session_set_save_handler(<br> array(__CLASS__,"open"),<br> array(__CLASS__,"close"),<br> array(__CLASS__,"read"),<br> array(__CLASS__,"write"),<br> array(__CLASS__,"destroy"),<br> array(__CLASS__,"gc")<br> );<br> <br> session_start();<br> }<br> <br> public static function open($path, $name){<br> return true;<br> }<br> <br> public static function close(){<br> return true;<br> }<br> <br> public static function read($PHPSESSID){<br> $sql="select PHPSESSID, update_time, client_ip, data from session where PHPSESSID= ?";<br> <br> $stmt=self::$handler->prepare($sql);<br> <br> $stmt->execute(array($PHPSESSID));<br> <br> if(!$result=$stmt->fetch(PDO::FETCH_ASSOC)){<br> return '';<br> }<br> <br> if( self::$ip != $result["client_ip"]){<br> self::destroy($PHPSESSID);<br> return '';<br> }<br> <br> if(($result["update_time"] + self::$lifetime) self::destroy($PHPSESSID);<br> return '';<br> }<br> <br> return $result['data'];<br> <br> }<br> <br> public static function write($PHPSESSID, $data){<br> $sql="select PHPSESSID, update_time, client_ip, data from session where PHPSESSID= ?";<br> <br> $stmt=self::$handler->prepare($sql);<br> <br> $stmt->execute(array($PHPSESSID));<br> <br> if($result=$stmt->fetch(PDO::FETCH_ASSOC)){<br> if($result['data'] != $data <br><font color="#FF8000">------解决方案--------------------</font><br> self::$time > ($result['update_time']+30)){<br> $sql="update session set update_time = ?, data =? where PHPSESSID = ?";<br> <br> $stm=self::$handler->prepare($sql);<br> $stm->execute(array(self::$time, $data, $PHPSESSID));<br> <br> }<br> }else{<br> if(!empty($data)){<br> $sql="insert into session(PHPSESSID, update_time, client_ip, data) values(?,?,?,?)"; <div class="clear"> </div>