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

**URL:** <https://www.phphelp.com/t/my-unset-only-triggers-when-i-successfully-load-my-second-page-how-can-i-fix-this/29624>\
**Category:** Help with WordPress\
**Created:** [July 31, 2019, 3:41pm UTC](https://www.phphelp.com/t/my-unset-only-triggers-when-i-successfully-load-my-second-page-how-can-i-fix-this/29624 "2019-07-31T15:41:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexlytle](https://www.phphelp.com/user_avatar/www.phphelp.com/alexlytle/32/2472_2.png) [@alexlytle](https://www.phphelp.com/u/alexlytle)\
**Post date:** [July 31, 2019, 3:41pm UTC](https://www.phphelp.com/t/my-unset-only-triggers-when-i-successfully-load-my-second-page-how-can-i-fix-this/29624/1 "2019-07-31T15:41:01Z")

</div>

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](https://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

```auto
<?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']);
```

---

<div class="post-metadata">

**Author:** ![chorn](https://www.phphelp.com/letter_avatar_proxy/v4/letter/c/b5ac83/32.png) [@chorn](https://www.phphelp.com/u/chorn)\
**Post date:** [August 1, 2019, 6:04am UTC](https://www.phphelp.com/t/my-unset-only-triggers-when-i-successfully-load-my-second-page-how-can-i-fix-this/29624/2 "2019-08-01T06:04:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alexlytle](https://www.phphelp.com/user_avatar/www.phphelp.com/alexlytle/32/2472_2.png) [@alexlytle](https://www.phphelp.com/u/alexlytle)\
**Post date:** [August 1, 2019, 6:27am UTC](https://www.phphelp.com/t/my-unset-only-triggers-when-i-successfully-load-my-second-page-how-can-i-fix-this/29624/3 "2019-08-01T06:27:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chorn](https://www.phphelp.com/letter_avatar_proxy/v4/letter/c/b5ac83/32.png) [@chorn](https://www.phphelp.com/u/chorn)\
**Post date:** [August 1, 2019, 7:13am UTC](https://www.phphelp.com/t/my-unset-only-triggers-when-i-successfully-load-my-second-page-how-can-i-fix-this/29624/4 "2019-08-01T07:13:26Z")

</div>

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.
