What is the purpose of session_regenerate_id() in PHP and how does it affect session management in a multi-session environment?
The purpose of session_regenerate_id() in PHP is to regenerate the session ID to prevent session fixation attacks. This function creates a new session ID and transfers all session data to the new session. In a multi-session environment, using session_regenerate_id() helps improve security by changing the session ID periodically.
// Start the session
session_start();
// Regenerate the session ID
session_regenerate_id(true);