I need to unset my session variables, when PayPal returns IPN.
The simplest script is the following
<?php
session_start();
unset($_SESSION['my_item']);
?>
Paypal sends IPN, all works fine, but after request my session variable save it’s value.
What can be a problem?
Thanks
UPDATE
As mentioned, when ipn sends request, it’s already another session, so i can do the following.
Before send user to paypal, set custom variable to current
session_id();
When paypal sends ipn, i can change current session to previus session, and clear it.
session_id($_POST[custom]);
session_start();
session_destroy(); //works fine
The problem here is that the IPN notification is not associated with the correct session.
The IPN is effectively a new session – it does not present the same session cookies that your client does, because you have not set them. Sessions are unique to a client, and the paypal gateway is a different client to that of your user.
You will need to bounce this information through a database. There is no sensible, easy way to have the IPN receiver directly modify the user’s session data.