public static function start(PDO $pdo) { self::$pdo = $pdo; self::$ctime = time(); self::$maxlifetime = ini_get("session.gc_maxlifetime"); self::$uip = !empty($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : (!empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : (!empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "")); //filter_var(self::$uip, FILTER_VALIDATE_IP) && self::$uip = ''; self::$uagent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; //注册过程, 让PHP自己处理session时,找这个函数指定的几个周期来完成 session_set_save_handler(array(__CLASS__, "open"), array(__CLASS__, "close"), array(__CLASS__, "read"), array(__CLASS__, "write"), array(__CLASS__, "destroy"), array(__CLASS__, "gc")); session_start(); //开启会话 }