PHP Session Variable to WordPress Error

You need to add your code to the functions.php file of your theme. (Actually, adding it to your Child Theme is best, since you don’t want a theme update changing things. Unless you are writing your own theme.)

So this in your functions.php file:

if(!session_id()) {
    session_start();
}