The description that session_name() gets and/or sets the name of the current session is technically wrong. It does nothing but deal with the value originally supplied by the session.name value within the php.ini file.
Thus:-
$name = session_name();
is functionally equivalent to
$name = ini_get('session.name');
and
session_name('newname);
is functionally equivalent to
ini_set('session.name','newname');
This also means that:
$old_name = session_name('newname');
is functionally equivalent to
$old_name = ini_set('session.name','newname');
The current value of session.name is not attached to a session until session_start() is called. Once session_start() has used session.name to lookup the session_id() in the cookie data the name becomes irrelevant as all further operations on the session data are keyed by the session_id().
Note that changing session.name while a session is currently active will not update the name in any session cookie. The new name does not take effect until the next call to session_start(), and this requires that the current session, which was created with the previous value for session.name, be closed.