title: Continue php script after connection close
body: <p>I am trying to continue a PHP Script after the page/connection is closed.</p>
  
  <p>Users will POLL the script in every 1 hour, I want to return some json output and want to continue the script in the background. I am using a shared host and I cannot use cron job.</p>
  
  <p>Here is what I've tried.</p>
  
  <pre><code>ob_start();
  
  ignore_user_abort();
  
  echo "JSON_OUTPUT GOES HERE";
  
  $ob_length = ob_get_length();
  
  header("Content-Type : text/plain",TRUE);
  header("Content-Length : $ob_length",TRUE);
  header("Connection : Close",TRUE);
  
  flush();
  ob_flush();
  ob_end_flush();
  
  sleep(3);
  
  echo "You cant see me..";
  
  exit();
  </code></pre>
  
  <p>I am using Codeigniter framework, But its not working on my live server. It waits 3 seconds and then outputting <code>You cant see me..</code> too.</p>
  
  <p>Please help me.</p>
  
  <h3>Note</h3>
  
  <p>Project is hosted in LINUX/WINDOWS/WAMP-SERVER shared hosts.</p>