Session failure, a strange failure solution

Source: Internet
Author: User
The session is invalid. it is strange that I have been writing paypal for the past two days. now I have completed ipn. php, but I am puzzled by a problem! Session is only valid in ipn. php. check the code PHPcode & lt ;? All phpipn. php code session_start (); include (ipnlistener. php); include_onc session is invalid, which is strange
I have been writing paypal for the past two days. now I have completed ipn. php, but I am puzzled by a problem!
Session is only valid in ipn. php. check the code.
PHP code
  
  Connect (); $ listener = new IpnListener (); $ listener-> use_sandbox = true; $ order_time = $ _ SESSION ['Order _ time_org ']; $ username = $ _ SESSION ['user']; echo "$ order_time, $ username"; // above this location, the SESSION can be used. the above two outputs can be displayed. // the following output cannot be displayed! Why? Try {$ verified = $ listener-> processIpn ();} catch (Exception $ e) {// fatal error trying to process IPN. exit (0);} if ($ verified) {// IPN response was "VERIFIED" // send email form $ invoice_id = $ _ POST ['invoice']; $ payment_status = $ _ POST ['payment _ status']; $ receiver_email = $ _ POST ['receiver _ email ']; $ payer_email = $ _ POST ['payer _ email ']; // $ order_time = $ _ POST ['custom']; // $ whimwin_user = $ _ SESSION ['use R']; // The $ _ SESSION ['user'] here cannot be displayed! // If ($ payment_status = "Completed ") // {$ query = "update cart set payment_status = 'paid' WHERE username = '$ username' AND order_time =' $ order_time 'AND invoice_id =' $ invoice_id '"; $ result = queryMysql ($ query); if ($ result) {$ to = "xxxx@gmail.com"; // payer_email // subject $ subject = "Whim Win paid successful! "; // From $ header =" from: test
  
   
"; // Message body $ message =" Dear Member, \ n "; $ message. = "this is you invoice id $ invoice_id \ n"; $ message. = "$ payment_status, $ order_time, $ payer_email, $ receiver_email, $ username"; // send email $ sendmail = mail ($ to, $ subject, $ message, $ header);} //} else {// IPN response was "INVALID"} $ db-> close ();?>
  


------ Solution --------------------
Test
Try {
Print_r ($ _ SESSION );
$ Verified = $ listener-> processIpn ();
Print_r ($ _ SESSION );
} Catch (Exception $ e ){
// Fatal error trying to process IPN.
Exit (0 );
}

------ Solution --------------------
Don't worry about him, just cache it yourself
Call it first.
Try {
$ Mysession =$ _ SESSION;
$ Verified = $ listener-> processIpn ();
$ _ SESSION = $ my_session;
} Catch (Exception $ e ){
// Fatal error trying to process IPN.
Exit (0 );
}
------ Solution --------------------
Your ipn. php file is the verify page successfully paid, right? I have an SQL statement that shows your update payment status.
If I guess it is correct, you need to make it clear that the customer's payment process is through a browser, so the cookie header can be resumed, however, the paypal request to notify you of the payment result on this page is completed through the palpay server, such as the curl commonly used by php. Therefore, if you do not explicitly send the current cookies to paypal and then include the cookies in the header of the paypal request, how can you read the session.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.