Destroy a session

Need a wrapper to manage session with phpunit

@return  void
487580
private static function sessionDestroy()
	{
		// Web
		if ( isset( $_SERVER['SERVER_PROTOCOL'] ) ) {
			Session::start();
			unset( $_SESSION['auth'] );
			$_SESSION['auth'] = array();
			Session::write_close();
		}
		// CLI
		else {
			$value = array();
			file_put_contents( '_cli_fake_session' , json_encode( $value ) );
		}
	}
468083
public function destroy()
    {
        $_SESSION = array();

        if (ini_get('session.use_cookies') and ! headers_sent()) {
            $params = session_get_cookie_params();
            setcookie(session_name(),
                      '',
                      time() - 42000,
                      $params['path'],
                      $params['domain'],
                      $params['secure'],
                      $params['httponly']
            );
        }

        if (! session_destroy()) {
            throw new Exception('Failed to destroy session');
        }

        $this->_setCsrfToken();

        return true;
    }
1193567
public function Destroy () {
		$name = $this->__name;
		$names = & static::$meta->names;
		$hoops = & static::$meta->hoops;
		$expirations = & static::$meta->expirations;
		$instances = & static::$instances;
		if (isset($names[$name])) unset($names[$name]);
		if (isset($hoops[$name])) unset($hoops[$name]);
		if (isset($expirations[$name])) unset($expirations[$name]);
		if (isset($_SESSION[$name])) unset($_SESSION[$name]);
		if (isset($instances[$name])) unset($instances[$name]);
	}
300603
public function destroy()
	{
		$this->clear();

		if (\ini_get('session.use_cookies'))
		{
			$params = \session_get_cookie_params();
			\setcookie(
				\ini_get('session.name'), '', time() - 4200,
				$params['path'], $params['domain'],
				$params['secure'], $params['httponly']
			);
		}

		$this->started = false;
		return \session_destroy();
	}
995724
public void destroySession() {
    	JsonObject session = get("session");
        if (session == null) {
            return;
        }

        String sessionId = session.getString("id");
        // remove from the context
        put("session", null);

        if (sessionId == null) {
            return;
        }

        store.destroy(sessionId, new Handler<Object>() {
            @Override
            public void handle(Object error) {
                if (error != null) {
                    // TODO: better handling of errors
                    System.err.println(error);
                }
            }
        });
    }
1332733
public function destroy($session_id = null)
    {
        if ($session_id) {
            $this->eventsManager->fireEvent('session:destroy', $this, ['session_id' => $session_id]);
            $this->do_destroy($session_id);
        } else {

            $context = $this->_context;

            if (!$context->started) {
                $this->_start();
            }

            $this->eventsManager->fireEvent('session:destroy', $this, ['session_id' => $session_id, 'context' => $context]);

            $context->started = false;
            $context->is_dirty = false;
            $context->session_id = null;
            $context->_SESSION = null;
            $this->do_destroy($context->session_id);

            $params = $this->_cookie_params;
            $this->cookies->delete($this->_name, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
        }
    }
343085
public function kill_all_sessions() {
        global $DB;
        if (!$this->connection) {
            return;
        }

        $rs = $DB->get_recordset('sessions', array(), 'id DESC', 'id, sid');
        foreach ($rs as $record) {
            $this->handler_destroy($record->sid);
        }
        $rs->close();
    }
337051
public function dispose() {
        parent::dispose(); // Call parent dispose to write/close session and other common stuff before closing connection

        if ($this->sqlsrv) {
            sqlsrv_close($this->sqlsrv);
            $this->sqlsrv = null;
        }
    }
72713
public function killSession()
    {
        $obj = new stdClass();

        $obj->Timestamp = $this->getSessionTimestamp();
        $obj->SessionID = $this->getSessionID();
        $obj->PinCode = $this->getPinCode();
        $obj->UserAgent = $this->getUserAgent();

        // Generate Checksum
        $obj->Checksum = $this->generateChecksum($obj);

        // PinCode only used for the Checksum
        unset($obj->Pincode);

        $session = $this->client->KillSession($obj);

        $this->unsetCookie();
        $this->unsetPHPSession();

        $this->_session = null;
        return (array) $session;
    }
1184558
public function expire()
    {
        if (!isset($_SESSION[$this->_index]) || !is_array($_SESSION[$this->_index]) || empty($_SESSION[$this->_index])) {
            return;
        }

        unset($_SESSION[$this->_index]);

        // Calling session_destroy triggers the Session::destroy function which removes the entire session
        // from the database. To prevent logout issues between functionality that relies on $_SESSION, such
        // as Symphony authentication or the Members extension, only delete the $_SESSION if it empty!
        if (empty($_SESSION)) {
            session_destroy();
        }
    }
336190
public function sessionDestroyer()
    {
        if (isset($this->objectSession) && $this->objectSession != NULL && is_object($this->objectSession)) {
            $this->logger->info(__FUNCTION__, 'Destroy Session with CI Session Class');
            $this->objectSession->sess_destroy();
        } else {
            $this->logger->info(__FUNCTION__, 'Destroy Session with The Http Foundation Component');
            $this->session->invalidate();
        }
    }
475102
public function destroy()
    {
        // Deletes session from the database
        if (isset($this->sessionId)) {
            $stmt = $this->db->prepare("DELETE FROM {$this->tableName} WHERE session_id = ?");
            $stmt->execute([$this->sessionId]);
        }

        // Kill the cookie, every possible way
        // https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet#Proper_Deletion
        setcookie($this->cookieName, '', 1);
        setcookie($this->cookieName, false);
        unset($_COOKIE[$this->cookieName]);
    }
780039
function destroyManager($force=false)
    {
        if ($this->getManager($force) !== null) {
            $key = $this->getSessionKey();
            $this->session->del($key);
        }
    }
274137
public function destroy()
    {
        if ( NULL !== $this->sessionID )
        {
            session_write_close();
        }
        elseif ( NULL === $this->sessionID && $this->strict )
        {
            throw new InvalidSessionException( 'There is no session to close' );
        }
    }
1052325
public function destroy()
    {
        parent::destroy();

     Logger::get()->debug('Destroying user ' . $this->id);
        // If this user is the one stored in the session, destroy that too.
        if (!empty($_SESSION) && ($_SESSION['current_user'] == $this)) {
            unset($_SESSION['current_user']);
        }
    }
485362
public function destroy()
    {
        try {
            $this->dispatch(new PerformUserLogout());
            return redirect($this->config->get('authentication.logout.redirectUri'));
        } catch (SessionHasExpired $e) {
            return redirect()->route('authentication::session.create')->withErrors([
               'authentication::login_warning' => $e->getMessage()
           ]);
        }
    }
627318
public function destroy(): void
    {
        if (!$this->cookieExists() || !$this->sessionExists()) {
            return;
        }

        session_destroy();

        // send expire cookies
        $this->expireSessionCookie();

        // clear session data
        unset($_SESSION[$this->getNamespace()]);
    }