/** * Creates a singleton session of the given type. Some session types * (native, database) also support restarting a session by passing a * session id as the second parameter. * * @param string type of session (native, cookie, etc) * @param string session identifier * @return Session */ public static function getInstance($id = NULL) { if (self::$instance === false) { // Create a new session instance self::$instance = $session = new self($id); // Write the session at shutdown register_shutdown_function(array($session, 'write')); } return self::$instance; }