Why does isset( $_SESSION['x'] ) return different results before and after HTML code in PHP?

When using `isset( $_SESSION['x'] )` in PHP, the session must be started before accessing or setting any session variables. If the session is not started before HTML code, the `isset( $_SESSION['x'] )` function may not work as expected. To solve this issue, make sure to start the session at the beginning of the PHP script, before any HTML code.

<?php
session_start(); // Start the session

// Check if $_SESSION['x'] is set
if (isset($_SESSION['x'])) {
    // Do something
}
?>
<!DOCTYPE html>
<html>
<head>
    <title>Session Example</title>
</head>
<body>
    <!-- Your HTML code here -->
</body>
</html>