What potential pitfalls can arise from not using the $_SESSION array for session variables in PHP?

Not using the $_SESSION array for session variables in PHP can lead to security vulnerabilities such as session hijacking or session fixation. It is important to always use the $_SESSION array to store and retrieve session variables securely.

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

// Set a session variable
$_SESSION['username'] = 'john_doe';

// Retrieve the session variable
$username = $_SESSION['username'];

// Destroy the session
session_destroy();
?>