PHP Code:
<?php
// Start the session to access session variables.
// This must be called at the very beginning of your script before any output.
session_start();
// Check if the 'username' session variable is set.
if (isset($_SESSION['username'])) {
$username = $_SESSION['username'];
echo "Hello, " . htmlspecialchars($username) . "!";
} else {
// If the username is not in the session, the user might not be logged in.
echo "Hello, Guest!";
// You might also redirect them to a login page here.
// header('Location: login.php');
// exit();
}
?>