title: Preventing page refresh after cookie consent accepting in PHP
body: <p>I just created a cookie consent banner for the website to accept cookies.
  Below is my complete code.</p>
  <pre><code>&lt;?php
      if (isset($_GET['accept-cookies'])) {
          setcookie('accept-cookies', 'true', time() + 31556925);
          header('Location: unit.php');
      }
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
      &lt;html&gt;
          &lt;head&gt;
              &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js&quot;&gt;&lt;/script&gt;
              &lt;style&gt;
                  body {
                      margin: 0;
                  }
                  .cookie-banner {
                      display: flex;
                      align-items: center;
                      justify-content: center;
                      background-color: #D4CFD3;
                      width: 100%;
                      position: fixed;
                      bottom: 2px;
                      left: 0;
                      font-size: 12px;
                  }
                  button {
                      background-color: #AEA9AD;
                      border: none;
                      color: #fff;
                      padding: 5px;
                      font-size: 12px;
                      border-radius: 5px;
                  }
                  button:hover {
                      cursor: pointer;
                  }
              &lt;/style&gt;
          &lt;/head&gt;
          &lt;body&gt;
          &lt;?php
              if (!isset($_COOKIE['accept-cookies'])) {
          ?&gt;
          &lt;div class=&quot;cookie-banner&quot;&gt;
              &lt;div class=&quot;container&quot;&gt;
                  &lt;p&gt;This website uses cookies. By using this website you consent to our use of these cookies. For more information visit our &lt;span&gt;&lt;a href=&quot;#&quot; &gt;Privacy Policy&lt;/a&gt;.&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;a href=&quot;?accept-cookies&quot; class=&quot;button&quot;&gt;&lt;button&gt;Accept!&lt;/button&gt;&lt;/a&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;?php
          }
          ?&gt;
          &lt;p&gt;This is a website&lt;/p&gt;
      &lt;/body&gt;   
  &lt;/html&gt;
  </code></pre>
  <p>It's working fine, but the page is getting refresh it's because of PHP header redirect used</p>
  <pre><code>header('Location: unit.php');
  </code></pre>
  <p>How can I prevent pages refreshing after clicking on the Accept button of the cookie consent banner? I want just the cookie banner to be invisible.</p>
  <p>Please help how can I do this.</p>
  <p>Thank you.</p>