I have been attempting to create a user login script in PHP, however I am met with an error telling that $_SESSION["username"] is undefined. I have session_start() inside of $_SERVER["DOCUMENT_ROOT"] . "/assets/php/main.header.php", however the variable still shows as undefined.
<?php
if (!isset($_SESSION["username"])) {
header("Location: /en/");
}
?>
<!DOCTYPE html>
<html>
<head>
<?php
include($_SERVER["DOCUMENT_ROOT"] . "/assets/php/main.header.php");
?>
<title>Profile | Project Club</title>
</head>
<body>
<h1>Profile</h1>
<p><?php echo $_SESSION["username"]?></p>
<?php
include($_SERVER["DOCUMENT_ROOT"] . "/assets/php/main.footer.php");
?>
</body>
</html>