title: Using PHP to reload a page with new div content
body: <p>I have a page that has main content and a menu bar, when a user logs in a $_SESSION variable is set via data pulled from a database to determine which main content and which menu bar the user sees.</p>
  <p>The main page is along the lines of:</p>
  <pre><code> &lt;div id=&quot;menu&quot;&gt;
      &lt;?php include_once '/files/'.$_SESSION['menu']; ?&gt;
      &lt;/div&gt;
  
      &lt;div&gt;
      &lt;?php include_once '/files/'.$_SESSION['content']; ?&gt;
      &lt;/div&gt;
  </code></pre>
  <p>When the user logs in the $_SESSION  variables are set to &quot;menu1.php&quot; and &quot;content1.php&quot; or &quot;menu2.php&quot; and &quot;content2.php&quot;, this works fine and the page loads correctly.</p>
  <p>I have then included two buttons on the both menu bars as such:</p>
  <pre><code>  &lt;form action='' method='POST'&gt;
        &lt;button type=&quot;submit&quot; name=&quot;set1&quot;&gt;Set 1&lt;/button&gt;
      &lt;/form&gt;
      &lt;form action='' method='POST'&gt;
        &lt;button type=&quot;submit&quot; name=&quot;set2&quot;&gt;Set 2&lt;/i&gt;&lt;/button&gt;
      &lt;/form&gt;
  </code></pre>
  <p>And two &quot;functions&quot;:</p>
  <pre><code> &lt;?php
        if(isset($_POST['set2'])){
              unset($_SESSION['menu']);
              unset($_SESSION['content']);
              $_SESSION['menu'] = 'menu2.php';
              $_SESSION['content'] = 'content2.php';
        };
        if(isset($_POST['set1'])){
              unset($_SESSION['menu']);
              unset($_SESSION['content']);
              $_SESSION['menu'] = 'menu1.php';
              $_SESSION['content'] = 'conent1.php';
        };
       ?&gt;
  </code></pre>
  <p>If you were to click the button to change the content and menu from 1 to 2, the page reloads with the correct content being shown &quot;content2&quot;, however, the menu bar remains at &quot;menu1&quot;, if you were to refresh the page only then does the menu change to &quot;menu2&quot;, it's as if the menu session is one refresh behind. This occurs vice versa from 2 to 1.</p>
  <p>What can be done so that when the page reloads, it reloads with both the new content and the new menu?</p>