Run code before WordPress loads and insert data into WP if need be

Unless performance is a huge factor, or you need to change PHP session globals, you don’t need to run anything before wordpress, just write a plugin that makes the checks needed on the init hook and die() if needed. This way you can also store the data wherever it is convenient for you.

For sure editing any wordpess core file is a big no-no which amount to forking wordpress with all the responsibilities it requires from you. The only file you may edit is wp-config.php but this should probably be done only if the plugin approach will not work

tech