title: How to send variable data when redirecting to previous page
body: <p>I am using the following codes to redirect my user to previous page after a particular task is done. </p>
  
  <pre><code>        if (isset($_SERVER['HTTP_REFERER']))
           {
           $this-&gt;session-&gt;set_userdata('previous_page', $_SERVER['HTTP_REFERER']);
           }
           else
           {
           $this-&gt;session-&gt;set_userdata('previous_page', base_url());
           }
  </code></pre>
  
  <p>The above code I use in a controller and the following code in another controller..</p>
  
  <pre><code>    .... some other stuffs... I am updating database values here....
  
          $this-&gt;db-&gt;where('t_expenseid', $t_expenseid);
          query=$this-&gt;db-&gt;update('teacherexpense', $data); 
  
  
          redirect($this-&gt;session-&gt;userdata('previous_page'));
  </code></pre>
  
  <p>The above code is working fine but the problem I am facing is I want to send a success message with the redirect so that when the previous page loads a success message pops up (I already have jquery for that). And for this I added the following code above the redirect, but I don't know how to send the $data or the message along with the redirect. And if I am able send it how to retrieve the value in the controller of the previous page.</p>
  
  <pre><code> $data['msg']='Information Has been Successfully Inserted'; 
  </code></pre>
  
  <p>Could you please tell me how to send it and then retrieve it?</p>
  
  <p>Thanks :)</p>