What are common issues related to PHP session handling, and how can they impact the functionality of a login system?

One common issue related to PHP session handling is session fixation, where an attacker sets a user's session ID before they log in, allowing them to hijack the session. To prevent this, regenerate the session ID after a successful login using session_regenerate_id(true).

session_start();

// Perform login process

if($login_successful){
    session_regenerate_id(true);
    // Redirect to logged-in page
}