What are the potential pitfalls of using session.auto_start in PHP and how can they be mitigated?

Using session.auto_start in PHP can lead to session fixation attacks, where an attacker can set the session ID before the session starts. To mitigate this, it is recommended to manually start the session when needed and regenerate the session ID to prevent fixation attacks.

<?php
// Manually start the session
session_start();

// Regenerate the session ID to prevent fixation attacks
session_regenerate_id(true);
?>