Moving authorizeUser to the top to allow cookie to be set without sessions already being sent warning