Pages

Thursday, September 12, 2013

How can I send headers then start a session?

  <?php 

  // make it or break it 

  error_reporting(E_ALL); 

  // begin output buffering 

  ob_start(); 

  // send a header 

  header ("Pragma: no-cache"); 

  // send some text to the browser 

  echo 'This is a line of text'; 

  // then we start our session  

  session_start(); 

  // set the value of the session variable 'foo' 

  $_SESSION['foo']='bar'; 

  // flush the buffer 

  ob_end_flush(); 

 ?>  


No comments:

Post a Comment