Occasionally users at our site are getting "Could not find a valid session key" messages when making payments through PayPal Standard. The payment succeeds but this message unsettles users.

The sequence of requests for a contribution is ...

  1. POST /civicrm/contribute/transact (submit payment details)
  2. GET /civicrm/contribute/transact?_qf_Confirm_display=true&qfKey=XXXXX
  3. POST /civicrm/contribute/transact (confirm payment details)
  4. POST /civicrm/payment/ipn/NNN (PayPal IPN callback)
  5. POST /civicrm/contribute/transact?_qf_ThankYou_display=1&qfKey=XXXXX

On the occasions when this fails the 5th step says "Could not find a valid session key". I'm unable to reproduce this on the PayPal Sandbox.

I'm running CiviCRM 5.10.4 (with security patches) on Drupal 7.67.

See this question for an update and a solution.


Ken West,

I guess your cron job 'Clean-up Temporary Data and Files' must be running when your site is busy. The session key is not an usual error. CiviCRM stores sessions variables into its database int the form of cache. When 'Clean-up Temporary Data and Files' schedule job is executed or CiviCRM cache is cleared manually the cache table is truncated. So when the user leaves CiviCRM and goes to Paypal standard for making payment and come backs to CiviCRM once payment is done and between these process CiviCRM cache is cleared than CiviCRM won't get the session key of the user from the cache table and you will end up the error message of session key invalid on screen.

Try if you can replicate using below step 1. Open 2 browsers(normal user and admin). 2. 1st browser - Do a donation, Click on confirm. 3. Once the user is on paypal screen(don't proceed with payment), from browser 2 clear civicrm cache. 4. From browser 1 proceed with payment in paypal

Solution: Try running the 'Clean-up Temporary Data and Files' schedule job once is a day when your site is not busy.



  • Thanks for the suggestion, @Pradeep. The clean-up job is currently configured to run once per day so that's probably not the cause. But I will check the logs. – Ken West May 27 '19 at 10:00
  • I tried the steps you suggested @pradeep-nayak but got a different message "Your browser session has expired and we are unable to complete your form submission". – Ken West May 27 '19 at 10:10
  • 1
    I tried the steps @Pradeep suggested but rather than clearing the cache I ran the clean-up job. The donation worked as expected. – Ken West May 27 '19 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.