开发者

Paypal IPN how to get current session

I want to get my previous $_SESSION['cart'] to the Paypal IPN

Sample of IPN Code I use. Everything working fine and script got the $_POST data from Paypal.

if (strcmp ($res, "VERIFIED") == 0) {
        $subject = time();
        $to      = 'my@email.com';
        foreach ($_POST as $key => $value) { 
      开发者_JAVA百科  $body .= "\n$key: $value";
        }
        mail($to, $subject, $body); 
}

Question

if (strcmp ($res, "VERIFIED") == 0) {
 // 1. How to get my previous $_SESSION['cart'] here? 
 // 2. When I call my $_SESSION['cart'] here not ouput will come & it's empty.
 // 3. Or this code only to get $_POST data from Paypal website only?
}


You can't because IPN is notified outside of your checkout process. It essentially is a background operation separate from the ordering/payment process of your website. If there is information in that session that you need to access you will need to store it in a database and then include some kind of identifier with it that is also passed to Paypal. Email addresses are usually good but a unique token, like a hash of some kind, is probably better. Then when the IPN notification comes in with that identifier you can pull that information out of the database and use as needed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜