What are the potential pitfalls of using a header to pass variables between pages in PHP?

Passing variables using headers in PHP can lead to potential security vulnerabilities such as injection attacks or exposing sensitive data. It is recommended to use sessions or cookies to pass variables between pages securely.

// Set variable in session
session_start();
$_SESSION['variable_name'] = $value;

// Redirect to another page
header('Location: another_page.php');
exit;