title: PayPal IPN losing session on return?
body: <p>I'm using Micha's PayPal IPN script and for the most part it worked great: <a href="https://github.com/Quixotix/PHP-PayPal-IPN" rel="nofollow">https://github.com/Quixotix/PHP-PayPal-IPN</a></p>
  
  <p>When i click Pay now on the website it redirects to paypal with correct information, allows payment to be made, but on return nothing happens, ie it does not upgrade the user as it should. Now i've tested the script my code outside of the IPN and it works perfect so it looks to me like the IPN script is losing the session? </p>
  
  <p>Here is my button code:</p>
  
  <pre><code>&lt;form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"&gt;
      &lt;input type="hidden" name="cmd" value="_xclick"&gt;
      &lt;input type="hidden" name="business" value="EMAIL_TO"&gt;
      &lt;input type="hidden" name="currency_code" value="GBP"&gt;
      &lt;input type="hidden" name="item_name" value="Text Light"&gt;
      &lt;input type="hidden" name="amount" value="0.01"&gt;
      &lt;input type="hidden" name="return" value="http://domain.co.uk/editors"&gt;
      &lt;input type="hidden" name="notify_url" value="http://domain.co.uk/account/upgrade"&gt;
      &lt;input type="submit" value="Pay now" class="btn btn-preview" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>So the notify url (IPN code) is /account/upgrade -- as far as i know this is where it should perform the upgrade task? so here is my (stripped down) code</p>
  
  <pre><code>if ($verified) {
  
      $errmsg = '';
  
      // some error checking
  
      if (!empty($errmsg)) {
  
          // manually investigate errors from the fraud checking
  
      } else {
  
          // upgrade user
          $package = serialize($_SESSION['package']);
          $this-&gt;db-&gt;update('users',array('id' =&gt; $_SESSION['user']['id']),array('payment_plan' =&gt; $package));
  
      }
  
  } else {
  
      // not verified, investigate problems
  }
  </code></pre>
  
  <p>As above, the code under '// upgrade user' works fine outside, but on return from paypal it's obviously not keeping hold of the session. It's not throwing any errors, it's just not doing anything.</p>
  
  <p>Where have i gone wrong? how can i ensure that session information will be passed back from PayPal.</p>
  
  <p>Thanks</p>