What are the advantages and disadvantages of using server-side file/directory management for creating a closed section on a website?

Using server-side file/directory management for creating a closed section on a website allows for more control over access permissions and security. It also enables easier organization and management of files and directories. However, it may require more technical expertise to set up and maintain, and there is a risk of accidentally exposing sensitive information if not properly configured.

<?php
// Check if user is logged in
session_start();
if(!isset($_SESSION['loggedIn']) || $_SESSION['loggedIn'] !== true) {
    header('Location: /login.php');
    exit;
}

// Display content for logged in users
echo "Welcome to the closed section of the website!";
?>