title: Save form data to SESSION variables before submit
body: <p>I have a form to submit data and I am using the following code for session variables</p>
  
  <pre><code>    if(!isset($_SESSION)) 
  { 
      session_start(); 
  } 
  if (isset($_SESSION['product'])) {
      $product = $_SESSION['product'];
      if($product == "loan"){$loan='selected="selected"';} else {$loan='';}
      if($product == "card"){$card='selected="selected"';} else {$card='';}
      if($product == "savings"){$savings='selected="selected"';} else {$savings='';}
      if($product == "morgage"){$mortgage='selected="selected"';} else {$mortgage='';}
  } else { $loan = $card = $savings = $mortgage = '';}
  if (isset($_SESSION['liked'])) {
      $liked = stripslashes(htmlspecialchars(($_SESSION['liked'])));
  } else {
      $liked = '';
  }
  if (isset($_SESSION['disliked'])) {
      $disliked = stripslashes(htmlspecialchars(($_SESSION['disliked'])));
  } else {
      $disliked = '';
  }
  </code></pre>
  
  <p>The form is something like this</p>
  
  <pre><code>        &lt;form id="msform" class="form-horizontal" method="POST" action=""&gt;
          &lt;label for="product"&gt;Select product:&lt;/label&gt;
            &lt;select name="product" id="product"&gt;
                &lt;option value="loan" '. $loan .'&gt;Personal Loan&lt;/option&gt;
                &lt;option value="card" '. $card .'&gt;Credit Card&lt;/option&gt;
                &lt;option value="savings" '. $savings .'&gt;Savings Account&lt;/option&gt;
                &lt;option value="mortgage" '. $mortgage .'&gt;Mortgage&lt;/option&gt;
              &lt;/select&gt; 
          &lt;textarea rows="4" name="liked" placeholder="I really liked..."&gt;'. $liked .'&lt;/textarea&gt;
          &lt;textarea rows="4" name="disliked" placeholder="I did not like..."&gt;'. $disliked .'&lt;/textarea&gt;
  
          &lt;!-- php if statements here, if logged in show submit button if not show Facebook login button --&gt;
  
          &lt;input type="submit" name="submit" class="submit action-button" value="Submit"/&gt;
  </code></pre>
  
  <p>The submit button is shown only to logged in users. If the user is not logged in a Facebook login button is shown. When he clicks on that he is sent to Facebook where if he accepts permissions of the app he is redirected back to the form as a logged in user. But then, all fields have been cleared. How can I save data to the session variables and repopulate it, if the GET/POST is not called yet?</p>