我应该将.HTML文件扩展名更改为.PHP以在每个页面中启用会话PHP吗?

I am a beginner in web development, so please understand me. On the question mentioned above, do I really need to convert the HTML file extension to PHP for me to enable the session and redirection of the page in the PHP?

For Example:

If the user is in the login form and not actually logged in, and just type only this on search bar https://sample.com/index.html it will redirect it on that page automatically even there is a code of PHP to redirect the user if he/she is not logged in on the Login Page. for example this code.

  if(!isset($_SESSION['login_user'])){
      header("Location: ../sample/login.html");
      die();
   }

but when the file extension is .PHP it actually works that even the user try to redirect using the search bar without user credential, it will show the 404 error, page not found.

I am getting this right? or is there anyway to Use the php sessions in .HTML file?

I hope someone understand me.. Thank you