title: Preserve session after redirect?
body: <p>if I var_dump my session variable before calling the redirect function, it looks okay. However, after redirecting to an external Clickabnk's payment page, I'm no longer able to access my session variable on the page after payment. </p>
  
  <p>I'm redirecting using the function below :</p>
  
  <pre><code>public function redirect($url) {
  if(!headers_sent()) {
      //If headers not sent yet... then do php redirect
      header('Location: '.$url);
      exit();
  } else {
      //If headers are sent... do javascript redirect... if javascript disabled, do html redirect.
      echo '&lt;script type="text/javascript"&gt;';
      echo 'window.location.href="'.$url.'";';
      echo '&lt;/script&gt;';
      echo '&lt;noscript&gt;';
      echo '&lt;meta http-equiv="refresh" content="0;url='.$url.'" /&gt;';
      echo '&lt;/noscript&gt;';
      exit();
  }
  exit();
  }
  </code></pre>
  
  <p>I'm using session_start on all scripts where I'm using sessions. </p>
  
  <p>The page below is the one that makes the redirection</p>
  
  <pre><code>&lt;?php 
  if(!session_id())  session_start();
  
  require_once("core.php");
  $core = new coreOptions();
  $options = $core-&gt;getChosenOptions();
  $numOptions = count($options);
  
  
  $url = "";
  
  
  switch($numOptions) {
  case 1:
  $url = $core-&gt;url1Options;
  break;
  case 2:
  $url = $core-&gt;url2Options;
  break;
  case 3:
  $url = $core-&gt;url3Options;
  break;
  case 4:
  $url = $core-&gt;url4Options;
  break;
  case 5:
  $url = $core-&gt;url5Options;
  break;
  case 6:
  $url = $core-&gt;url6Options;
  break;
  case 7:
  $url = $core-&gt;url7Options;
  break;
  case 8:
  $url = $core-&gt;url8Options;
  break;
  case 9:
  $url = $core-&gt;url9Options;
  break;
  default:
  $url = $core-&gt;urldefaultOptions;
  break;
  
  }
  
  
  $core-&gt;redirect($url);
  exit();
  
  ?&gt;
  </code></pre>
  
  <p>Below is the content of core.php </p>
  
  <pre><code>.....
  // get options
  public function getChosenOptions(){
  if (isset($_SESSION["chosenOptions"])) return $_SESSION["chosenOptions"];
  return false;
  }
  
  // set options
  public function setChosenOptions($c) {
  $_SESSION["chosenOptions"] = $c;
  }
  
   .....
   // function to redirect to given page
  public function redirect($url) {
  if(!headers_sent()) {
      //If headers not sent yet... then do php redirect
      header('Location: '.$url);
      exit();
  } else {
      //If headers are sent... do javascript redirect... if javascript disabled, do html redirect.
      echo '&lt;script type="text/javascript"&gt;';
      echo 'window.location.href="'.$url.'";';
      echo '&lt;/script&gt;';
      echo '&lt;noscript&gt;';
      echo '&lt;meta http-equiv="refresh" content="0;url='.$url.'" /&gt;';
      echo '&lt;/noscript&gt;';
      exit();
  }
  exit();
  }
  .....
  </code></pre>
  
  <p>The page below is the one I want to access the $_SESSION["chosenOptions"] from.  Why the page below cannot access the session variable although it was set correctly in the page that makes the redirection? : </p>
  
  <pre><code> &lt;?php if(!session_id())  session_start();
  
  
  require_once("core.php");
  $core = new coreOptions();
  $uid = $core-&gt;uid();
  $options = $core-&gt;getChosenOptions();
  var_dump($options); // this line shows NULL. Why ?
  if (empty($options)) exit("Options Is Empty");
  
  if (count((array)$options)&gt;0) {
  
  try {
      $conn = new PDO() // stripped conn data
      $conn-&gt;exec("SET CHARACTER SET utf8");      // Sets encoding UTF-8
      $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
      $sql = "INSERT INTO availablecommands (for_whom, oname, is_available) VALUES (:fw, :on, :ia)";
      $statement = $conn-&gt;prepare($sql);
  
      foreach($options as $o) {
      $statement-&gt;bindValue(":fw", $uid);
      $statement-&gt;bindValue(":on", $o);
      $statement-&gt;bindValue(":ia", 1);
      $count = $statement-&gt;execute();
      $conn = null;       // Disconnect
  
      }
  
      }
      catch(PDOException $e) {
          echo $e-&gt;getMessage();
      }
  
  
  
  }
  
  
  $core-&gt;redirect("dashboard.php");
  
  
  
  ?&gt;
  </code></pre>