将 $award_id 存储在 cookie 中 - PHP

Storing $award_id in a cookie - PHP

我创建了一个MYBB论坛wadakela.xyz. I have added newPoints Awards System in it. Which is integrated with CoinPayments供用户购买。

img: https://i.imgur.com/sI7Edly.png

现在,例如我有 5 个奖励,用户购买了第 3 个。我有脚本文件,它会向我发送电子邮件和 PM,通知“this”用户已使用“this award ID”购买了一个奖项当用户进入成功(从支付回调)页面时。

图像:https://imgur.com/a/fzR1qQl

最初,当它没有与 coinpayments 集成时,我使用 POST 方法在有人通过奖励页面单击“购买”按钮时从表单中获取奖励 ID,这实际上工作正常。我可以使用此代码获得正确的 ID。

//awards page
<input type="hidden" name="award" value="{$award['aid']}">

//success page
$award_id = $_POST['award'];

现在它与 CoinPayments 集成,它不会直接进入 success.php 所以 POST方法不起作用。如果我没记错的话,我可以通过 cookies(或者会话?)在 success.php 中获得奖励 ID。但是,我未能将奖励 ID 存储在 cookie 中。

据我们所知,现在是这样的:

-奖励页面->硬币支付网站->成功页面。

为了从 奖励页面 成功页面 获取奖励 ID,我尝试了以下代码将奖励 ID 存储到 cookie 中:

//in awards page
setcookie("award",$award['aid'], time()+300);

//in the form
<input type="hidden" name="award" value="{$award['aid']}">


....processing with coinpayments....



//in success (callback) page
$award_id = $_COOKIE["award"];

echo $award_id;  //pm + email actually.

setcookie("award",$award_id, time()-60);

在成功页面,$award_id总是returns“5”。可能是因为列出了 5 个奖项?

除此之外,整个过程非常顺利并且按预期工作。 我想做的是在 cookie 中存储正确的奖励 ID。

如果有人能帮我解决这个问题,我将不胜感激。如果有任何替代方法可以实现这一点,我也想知道。

而且,我真的需要在今天之前完成它..

如果您需要更多信息,请告诉我。

谢谢。 :)

成功 URL 不能用作 IPN。相反,IPN 需要 return POST 数据。

<input type="hidden" name="ipn_url" value="https://wadakela.xyz/YOURIPNFILE.php">
<input type="hidden" name="ipn_type" value="simple">

此处 YOURIPNFILE 将 return POSTed 数据。