What potential pitfalls should developers be aware of when using session_regenerate_id to secure PHP sessions?

When using session_regenerate_id to secure PHP sessions, developers should be aware of potential race conditions that could occur if multiple requests are made simultaneously. To avoid this, developers should use session_write_close() before calling session_regenerate_id() to ensure that the session data is written and the session is closed before generating a new ID.

session_start();
session_write_close();
session_regenerate_id(true);