How to redirect programmatically inside a module to an external url?
Well if you want to redirect to an external page this can be your code:

&lt;?php

namespace Drupal\achva_sso\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Routing\TrustedRedirectResponse;

class SsoController extends ControllerBase{
    public function ssoLogout(){
        unset($_SESSION['name']);

        // Redirect.
        return new TrustedRedirectResponse('http://www.bbc.com/');

    }
}


In this case, the redirection will happen when your ssoLogout() method will be called.