当在2个html文件中调用相同的php文件时,会话变量不起作用

I'm making a site for the doctors to use. Once they login, I'm creating a session variable $doctorid=$_SESSION['DOCTOR_ID']; After this I'm retrieving the data from the database using load_user.php and I echo it to the view.html file.

This is being used to get the doctor's name on the top right side in the website, i.e, on the navbar.

Now the problem is when I make another HTML file to get the same navbar on the page by calling the same load_user.php file, the navbar is not being displayed.

I have included the code of both the files below:

load_user.php

<?php
session_start();
$doctorid=$_SESSION['DOCTOR_ID'];
if($doctorid==-1 || !isset($_SESSION['DOCTOR_ID'])){
    echo "<script>window.location.href='index.html';</script>";
    exit(0);
}
$results=execute_MYSQL("SELECT * FROM DOCTORS WHERE  DOCTOR_ID=$doctorid");
echo "<script>console.log('SELECT * FROM DOCTORS WHERE DOCTOR_ID=$doctorid');</script>";


if($results->num_rows==1){
  $row = $results->fetch_assoc();
  $doctor_name=$row['DOCTOR_NAME'];
  $doctor_email=$row['DOCTOR_EMAIL'];
  $doctor_designation=$row['DOCTOR_DESIGNATION'];

echo"   <ul class='nav'>
      <li>
        <img id='doctor_image' src='bci-logo.png'>
      </li>
      <li>
      <a href='#'>BLUE CROSS OF INDIA</a>
    </li>
    <li style='float:right'>";

if(file_exists('user_images/'.$doctorid.'.jpg')){
echo "<img id='doctor_image' src='user_images/$doctorid.jpg' alt=\"Image not found\" onError=\"this.src='user_images/default.png'\">";
}
else{
echo "<img id='doctor_image' src='user_images/default.jpg' alt=\"Image  not found\" onError=\"this.src='user_images/default.png'\">
      <!--<form id='upload_image' method='post' enctype='multipart/form-data'><input id='fileToUpload' type='file' accept='image/*' name='fileToUpload'/><div id='upload_image' onclick='upload_image()'>Upload DP</div></form>-->";
  }


echo" </li>
    <li id='options' style='float:right'>
    <a href='#' id='docid'> Dr. ".$doctor_name." </a>
    <ul class='subnav'>
            <li><a href='#'>Settings</a></li>";
if($doctorid==0)
{
    echo"<li><a href='#'   onclick='window.location.href=\"view_users.html\"'>View Doctors</a></li>
     <li><a href='#' onclick='window.location.href=\"add_user.html\"'>Add Doctor</a></li>";
      //<div id='edit_user' onclick='window.location.href=\"edit_user.html\"'>Edit Profile</div>
}
    echo "<li><a href='#' onclick='activate_logOut()'>Log Out</a></li>
          </ul>
          </li>
          <li id='search' style='float:right'>
                <form action='' method='get'>
                    <input type='text' name='search_text'  id='search_text' placeholder='Search'/>
                    <input type='button' name='search_button' id='search_button'></a>
                </form>
            </li></ul>";
  }

function execute_MYSQL($sql){
 //DATABASE DETAILS
  }?>

view.html

<html>

<div id="doctor_pane1">

</div>

</html>