When should session_start() be called in PHP scripts to ensure proper functionality?

To ensure proper functionality of sessions in PHP scripts, the session_start() function should be called at the beginning of the script before any output is sent to the browser. This is because session_start() initializes a session or resumes the current one, and should be called before any session variables are accessed or modified.

<?php
session_start();

// Your PHP code here
?>