How to redirect programmatically inside a module to an external url? I am trying to redirect to a page after I unset a session.
I read this article but I am pretty new to Drupal module building. 

Here this amazing guy says to do the comming thing:


  If you know that the destination is an external URL then you are
  encouraged to use TrustedRedirectResponse instead:

return new RedirectResponse(\Drupal::url('&lt;front&gt;', [], ['absolute' =&gt; TRUE]));
  return new TrustedRedirectResponse('http://www.bbc.com/');



I don't understand how I should use this code and where to put it...

Any help would be great 
This is my controller file content. 

&lt;?php

namespace Drupal\achva_sso\Controller;

use Drupal\Core\Controller\ControllerBase;


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

        if(isset($_SESSION['name'])){
            $status = $_SESSION['name'] .' is logged in';
        }else{
            $status = 'is logged out';
        }
        return[
            '#type' =&gt; 'markup',
            '#markup' =&gt; '&lt;p&gt;' . $status . '&lt;/p&gt;' ,
        ];


    }
}
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.