What is the best practice for passing sessions to included classes in PHP?

When passing sessions to included classes in PHP, the best practice is to use the session_start() function at the beginning of each script that will use sessions, including any included classes. This ensures that the session is started before any session variables are accessed or modified within the included classes.

// Include this at the beginning of each script that will use sessions
session_start();

// Include the class that will use sessions
include 'YourClass.php';

// Create an instance of the class
$yourClass = new YourClass();

// Access session variables within the included class
$yourClass->getSessionData();