/** * @see \herosphp\session\interfaces\ISession::start(). * @param null $config * @return mixed|void */ public static function start($config = null) { //初始化配置信息 self::$config = $config; self::$sessionSavePath = $config["session_save_path"]; if (!file_exists(self::$sessionSavePath)) { FileUtils::makeFileDirs(self::$sessionSavePath); } if (!is_writable(self::$sessionSavePath)) { E("session 目录" . self::$sessionSavePath . "不可写,请更改权限。"); } //初始化用户ip self::$userIp = $_SERVER['REMOTE_ADDR']; session_set_save_handler(array(__CLASS__, 'open'), array(__CLASS__, 'close'), array(__CLASS__, 'read'), array(__CLASS__, 'write'), array(__CLASS__, 'destroy'), array(__CLASS__, 'gc')); @session_start(); }
/** * @see \herosphp\session\interfaces\ISession::start(). */ public static function start($config = NULL) { //初始化配置信息 if (!$config) { self::$config = array('session_file_prefix' => 'heros_sess_', 'session_update_interval' => 30, 'gc_maxlifetime' => 1440); } else { self::$config = $config; } if (!self::$config['gc_maxlifetime']) { self::$config['gc_maxlifetime'] = ini_get('session.gc_maxlifetime'); } //初始化用户ip self::$userIp = $_SERVER['REMOTE_ADDR']; session_set_save_handler(array(__CLASS__, 'open'), array(__CLASS__, 'close'), array(__CLASS__, 'read'), array(__CLASS__, 'write'), array(__CLASS__, 'destroy'), array(__CLASS__, 'gc')); @session_start(); }