What potential pitfalls can occur when using session_start() in PHP, especially when dealing with headers already sent?

When using session_start() in PHP, a potential pitfall is encountering the "headers already sent" error if there is any output sent to the browser before session_start() is called. To avoid this issue, make sure to call session_start() before any output is sent to the browser, such as HTML, whitespace, or even error messages.

<?php
// Start the session before any output is sent
session_start();

// Your PHP code here
?>