title: How to display error messages in CodeIgniter
body: <p>In my controller I put this code to check if the shopping cart is empty:</p>
  
  <pre><code>if (!$this-&gt;cart-&gt;contents()){
      $this-&gt;session-&gt;set_flashdata('message', 'Your cart is empty!');
  }
  
  $this-&gt;data['message'] = $this-&gt;session-&gt;flashdata('message');
  
  $this-&gt;load-&gt;view('templates/header', $this-&gt;data);
  $this-&gt;load-&gt;view('bookings', $this-&gt;data);
  $this-&gt;load-&gt;view('templates/footer');
  </code></pre>
  
  <p>On my "bookings" view I set this code to display the message:</p>
  
  <pre><code>&lt;div id="infoMessage"&gt;&lt;?php echo $message;?&gt;&lt;/div&gt;
  </code></pre>
  
  <p>But on the first page load the message "Your cart is empty!" is not showing. However, it will display when I press the F5 key or refresh the browser.</p>
  
  <p>I have already read the manual from codeigniter that says "CodeIgniter supports "flashdata", or session data that will only be available for the next server request, and are then automatically cleared."</p>
  
  <p>However, I don't know where to set this message so it will be available on "next server requrest".</p>