Is it recommended to use ini_set() to change the session save path in PHP scripts, or are there better alternatives?

When changing the session save path in PHP scripts, it is recommended to use the session_save_path() function instead of ini_set(). This ensures that the session save path is set specifically for the session functions and does not affect other parts of the script that may rely on the default save path.

<?php
// Set the session save path using session_save_path()
session_save_path('/path/to/save/session');
// Start the session
session_start();
?>