Why is it necessary to create a new instance of the Login class ($user = new Login();) before each function call in the code?

Creating a new instance of the Login class before each function call ensures that each function operates on a separate instance of the class, preventing any unintended side effects or conflicts between function calls. This practice ensures that the class properties and methods are isolated for each function call, maintaining the integrity of the Login functionality.

class Login {
    // Class implementation
}

// Create a new instance of the Login class before each function call
$user = new Login();
$user->loginUser();
$user = new Login();
$user->logoutUser();