What are common pitfalls when using PHP sessions to pass variables between files?

One common pitfall when using PHP sessions to pass variables between files is forgetting to start the session in each file where the session variables are being accessed. To solve this, make sure to call session_start() at the beginning of each file that needs access to session variables.

<?php
// File 1: start_session.php
session_start();
$_SESSION['variable'] = 'value';
?>

<?php
// File 2: get_session_variable.php
session_start();
echo $_SESSION['variable'];
?>