Pass variables from one widget to another widget

You don’t need to make it global.

If your include a file from within a functions scope, any variables that you defined in that function (before that point) will be exposed in the included file as well.

But because the variable you are talking about represents the state of the footer file inclusion (if I understood correctly), you can make it a static variable:

class You_Widget{

    protected static
      $footerIncluded = false;

    public function widget(){

      // this will only run once
      if(!self::$footerIncluded){        
        include __DIR__ . '/footer.php';
        self::$footerIncluded = true;
      }

    }

}