title: PHP & JS - Cookie value in If Statement causes Bug
body: <p>I am trying to make a function with HTML, JS and PHP that does the following:</p>
  <ol>
  <li>When a HTML &quot;button&quot; is pressed, it gives values to a <code>$_GET</code> array;</li>
  <li>When those values exist on the <code>$_GET</code> array it pops up a JavaScript confirm window;</li>
  <li>If the user presses &quot;OK&quot; the JS gives to a <code>$_COOKIE</code> array the value of <code>true</code>. If the user presses &quot;CANCEL&quot; JS gives to <code>$_COOKIE</code> array the value of <code>false</code>;</li>
  <li>For last the <code>$_COOKIE</code> array is checked with PHP, and if it is <code>true</code> it does something. Otherwise it doesn't do nothing.</li>
  </ol>
  <p>Where is the code for each step:</p>
  <pre><code>// STEP 1
  &lt;a href=&quot;page.php?remove=true&amp;id-organ=1&quot;&gt;Remove&lt;/a&gt;
  
  // STEP 2 AND 3
  if (isset($_GET['remove']) &amp;&amp; isset($_GET['id-organ'])) {
         echo '
             &lt;script&gt;
                  var option = confirm(&quot;REMOVE?&quot;);
                  if (option == true) {
                      document.cookie = &quot;option = true&quot;;
                  } else {
                      document.cookie = &quot;option = false&quot;;
                  }
             &lt;/script&gt;
         ';
  }
  
  // STEP 4
  if ($_COOKIE['option'] == true) {
      echo '
          &lt;script&gt;
              window.alert(&quot;ORGAN WAS REMOVED!\n&quot;);
          &lt;/script&gt;
      ';
      
  } 
  </code></pre>
  <p><strong>If JS Confirm Window &quot;OK&quot; is pressed everything works fine, awesome, with no problem.</strong></p>
  <p><strong>If JS Confirm Window &quot;CANCEL&quot; is pressed, the STEP 4 if statement happens anyway.</strong></p>
  <ul>
  <li>I have tried to <code>console.log(option)</code> which is false for CANCEL
  button.</li>
  <li>I have tried to <code>echo $_COOKIE['option']</code> wihch is also false
  for CANCEL button.</li>
  </ul>
  <p>This make no sense being literally against all&quot;programming physics&quot;. . .</p>
  <p>Can someone tell me why is this happening? Am I doing something wrong? Is there a better way for this type of functionality?</p>