My unset() only triggers when I successfully load my second page. How can i fix this

I’m trying to creat two consecutive pages, where you have to go to the first page to have access to the second page. I’m doing this in WordPress and trying to add PHP code snippets to make this work. I have it working but only every other time. If you go to this link //www.lytrod.com/intellicut-install-demo. it will only redirect every other time

I set the variable on page 1

<?php session_start(); $_SESSION[ 'display_page2' ] = TRUE; ?>

Page:2

<?php

session_start();

if ((isset($_SESSION['display_page2']) && $_SESSION['display_page2'] === true) || isset($_POST['nf-field-184'])) {
    //run page two
} else {
    header('Location:http://www.lytrod.com/intellicutinstallation-2/');
}
// clears the variable
unset($_SESSION['display_page2']);

if it does not redirect, not all conditions match, so you have to debug each conditon, what you can do with var_dump like

var_dump((isset($_SESSION['display_page2']) && $_SESSION['display_page2'] === true) || isset($_POST['nf-field-184']));

and any other part of the condition

I feel like I have gone through all the conditions. Whats really weird is that it works every other time. I’ll click the link and it works then I click and doesn’t. … So on and so on

so you have to check every condition every time. At some point the conditions will result in true, and the other time in false, and from there you have to go back to where you build up the data for these conditions. But you won’t get any further if you don’t determine which condition failes in detail.

Sponsor our Newsletter | Privacy Policy | Terms of Service