title: What happens to the $_SESSION array if a PHP session times out in the middle of a request?
body: <p>I have always wondered, if a PHP session times out during the middle of executing a script, will the contents of the $_SESSION array still be available until script execution ends? For example:</p>
  
  <pre><code>session_start();
  
  if(! isset($_SESSION['name'])) {
      echo 'Name is not set';
      exit;
  }
  
  // imagine there is a bunch of code here and that the session times out while
  // this code is being executed
  
  echo 'Name is ', $_SESSION['name']; // will this line throw an error?
  </code></pre>
  
  <p>Is it practical to copy session variables to the local scope so I can read them later on in the script without having to keep checking for a session time out? Something like:</p>
  
  <pre><code>session_start();
  
  if(isset($_SESSION['name'])) {
      $name = $_SESSION['name'];
  } else {
      echo 'Name is not set';
      exit;
  }
  
  // bunch of code here
  
  echo 'Name is ', $name;
  </code></pre>