Jump to content

[SOLVED] POST a form and empty the session


Omzy

Recommended Posts

cart.php:

 

echo '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';

foreach($_SESSION as $index => $value)
{
echo '<input type="hidden" name="'.$index.'" value="'.$value.'" />';
}

echo '<input type="submit" value="Checkout Now" /></form>';

 

I want the $_SESSION to be emptied/destroyed once the form has been submitted.

Then no it won't, but the theory is the same regardless. You need to track whether the form is submitted, so you must have a value somewhere, be it in the $_SESSION or wherever, simply check that value then destroy the session.

It's pretty much straightforward I would have thought?

 

cart.php is a shopping cart, as the filename would suggest. When the user is happy with the contents of the cart they can hit "Checkout Now" which is a submit button linked to a form which posts the SESSION variables to PayPal. The PayPal screen opens in the same window.

 

All I want is for the SESSION to be destroyed if the user submits the form. If they don't submit the form then everything stays as it is!

Well this is it - I'm not doing a "full" integration - PayPal does indeed send back notifications but it's a b*tch to implement and not worth the hassle when all I want to do is clear the session! That's why I'm trying to do it the easy way - but evidently it does not seem to be any easier!

No, it's not. The only work around I can think of would be to POST to a page of your own, on that page use cURL to submit the information to PayPal, then reset your Session. But I suspect that will be no easier that using 'proper' integration.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.