Here, we are setting an error message to the session variable if the user enters an invalid username. We then redirect the user to the login page and exit the script. This function is a built-in PHP function and does not require any external package libraries.