Hope this is not out of php.net noting scope.
session_name('name') must be set before session_start() because the former changes ini settings and the latter reads them. For the same reason session_set_cookie_params($options) must be set before session_start() as well.
I find it best to do the following.
function is_session_started()
{
if (php_sapi_name() === 'cli')
return false;
if (version_compare(phpversion(), '5.4.0', '>='))
return session_status() === PHP_SESSION_ACTIVE;
return session_id() !== '';
}
if (!is_session_started()) {
session_name($session_name);
session_set_cookie_params($cookie_options);
session_start();
}