How do I check login? I have a php file in my Drupal 8 module.The name of my custom module is fb. Within the fb folder I have a php file fb.php .The content of that file is loaded as an iframe using the follwing code
  public function buildForm(array $form, FormStateInterface $form_state) {
  $extpath = take_control_fb_ext_client_path();
  $fbpath = take_control_client_path(drupal_get_path('module', 'fb') . '/fb.php?extpath=' . $extpath);
  global $base_url;
  $form['#attached']['take_Control_fb']['library'][] = 'fb/fb';
      $form = array(
      'take_control_fb_container' => [
    '#type' => 'inline_template',
    '#template' => '',
    '#context' => [
      'url' => '/modules/fb/fb.php?extpath=/libraries/extjs/ext-3.4.1'
  ],
],
  );
return $form;
  }

.I need to check drupal login is set or not in the fb.php file.  I have used the following code to check that

$logged_in = \Drupal::currentUser()->isAuthenticated();

Ref link : https://docs.acquia.com/articles/there-drupal-function-check-if-user-logged

But it resulted the error 'PHP Fatal error:  Class 'Drupal' not found'.

Please help me to figure out some solution to fix this.
The correct approach for this would be to implement a service, in which you put the contents of the fb.php and there all the Drupal functions will be recognized.
Here is an example of a service implementation: https://docs.acquia.com/articles/drupal-8-services-dependency-injection-and-service-containers