What are the best practices for handling sessions in PHP across different directories?

When handling sessions in PHP across different directories, it is important to set the session save path to a common directory accessible by all scripts. This ensures that session data can be stored and retrieved consistently across different directories.

<?php
// Set the session save path to a common directory
session_save_path('/path/to/common/directory');
session_start();

// Your PHP code here
?>