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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.