It sounds like the session_start() is failing (on one or both pages), which would be producing a php error. Do you have php’s error_reporting set to E_ALL (it should always be this value) and temporarily for debugging do you have php’s display_errors set to ON or do you have php’s log_errors set to ON and you are checking the web server’s error log? All of the php error settings should be in the php.ini on your system, so that they can be set or changed at a single point.
You could also be redirecting and changing the url (host name, i.e. WWW in a url vs no WWW in a url) such that a session started on one page doesn’t exist on the second page.
What does adding
var_dump($_SESSION); immediately after the session_start() show?
This also points out a lack of validation and User eXperience (UX) logic in your code. If you were validating inputs and testing if queries (didn’t) match any rows, and were outputting useful messages in these cases, your code would help you pin down that cause of the problem. You do have logic testing if a query matches any row(s), but it doesn’t do anything for the false/else case.
You need to validate inputs to your code. If a ‘required’ input is not present, set up a message telling the user what required input is missing. If an input is optional, set up a default value for it when it doesn’t exist. If a database query is expected/required to match data for the page to work, but it doesn’t, set up a message telling the user that a required piece of data wasn’t found. If data from a database query is optional, set up a default value for it when it doesn’t exist.
BTW - because you set the mysqli error mode to use exceptions, none of the discrete error handling logic in your code will ever be executed and should be removed. On a mysqli error, execution will transfer to the nearest exception handling, which will be php if you don’t have any in your code.