Error: "Error type: Could not find a valid session key."

This is similar to a number of other times people have run into this problem, but I've looked through all of those here on StackExchange, have tried those things, and have not found any luck yet.

When donating via a contribution page, receive an HTTP 500 error instead of the thank-you page and thank-you email receipt. The contribution record is logged into the database, but the website can't go to the right page because the session key is invalid. It is going to https://example.org/civicrm/?page=CiviCRM&q=civicrm/contribute/transact

This used to work fine. Recently moved to new server, updated civicrm.settings.php and the Directories and Resource URLs pages appropriately.

Any ideas? Am I missing something really obvious?

I could always go up to Stripe 5.2 and CiviCRM 5.3, but was hoping to be able to fix it in this version.

Cookies are enabled in the browser. Have reproduced in 2 browsers and on 2 machines.

Error details:

Feb 05 16:07:33 [info] $Fatal Error Details = Array ( [message] => We can't load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled). Then try again. If this error persists, contact the site administrator for assistance.<br /><br />Site Administrators: This error may indicate that users are accessing this page using a domain or URL other than the configured Base URL. EXAMPLE: Base URL is http://example.org, but some users are accessing the page via http://www.example.org or a domain alias like http://myotherexample.org.<br /><br />Error type: Could not find a valid session key. [code] => )

Feb 05 16:07:33 [info] $backTrace = /home/example/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(378): CRM_Core_Error::backtrace("backTrace", TRUE)

/home/example/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(833): CRM_Core_Error::fatal("We can't load the requested web page. This page requires cookies to be enable...")

/home/example/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(853): CRM_Core_Controller->invalidKeyCommon()

/home/example/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Controller/Contribution.php(74): CRM_Core_Controller->invalidKeyRedirect()

/home/example/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(312): CRM_Contribute_Controller_Contribution->invalidKey()

/home/example/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(204): CRM_Core_Controller->key("CRM_Contribute_Controller_Contribution", TRUE, FALSE)

/home/example/public_html/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Controller/Contribution.php(55): CRM_Core_Controller->__construct("CiviContribute", "null")

/home/example/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(304): CRM_Contribute_Controller_Contribution->__construct("CiviContribute", TRUE, "null", NULL, "false")

/home/example/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:15))

/home/example/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))

/home/example/public_html/wp-content/plugins/civicrm/civicrm.php(1216): CRM_Core_Invoke::invoke((Array:3))

/home/example/public_html/wp-content/plugins/civicrm/includes/civicrm.basepage.php(141): CiviCRM_For_WordPress->invoke() internal function: CiviCRM_For_WordPress_Basepage->basepage_handler(Object(WP))

/home/example/public_html/wp-includes/plugin.php(579): call_user_func_array((Array:2), (Array:1))

/home/example/public_html/wp-includes/class-wp.php(633): do_action_ref_array("wp", (Array:1))

/home/example/public_html/wp-includes/functions.php(886): WP->main("")

/home/example/public_html/wp-blog-header.php(14): wp()

/home/example/public_html/index.php(17): require("/home/example/public_html/wp-blog-header.php") {main}


Wordpress 4.3.6
CiviCRM 4.7.30
Stripe payment processor extension  4.7.3
PHP 5.6

CIVICRM_UF_BASEURL from civicrm.settings.php, Site address, and WP address are identical

Path Variables:

[cms.root]      /home/example/public_html
[civicrm.root]  /home/example/public_html/wp-content/plugins/civicrm/civicrm
[civicrm.files] /home/example/public_html/wp-content/uploads/civicrm

Resource URLs: (these all look right)

CiviCRM Resource URL      [civicrm.root]/
Image Upload URL          [civicrm.files]/persist/contribute/
Extension Resource URL    /wp-content/plugins/files/civicrm/

Directories: (these all look right)

Temporary Files Directory    [civicrm.files]/upload/
Image Directory              [civicrm.files]/persist/contribute/
Custom Files Directory       [civicrm.files]/custom/
Extensions Directory         /home/example/public_html/wp-content/plugins/files/civicrm/

HTTPS is forced. For example, http://www.example.org resolves to https://example.org.

in .htaccess:

# Redirect to HTTPS
 RewriteCond %{HTTPS} off
 RewriteCond %{HTTP:X-Forwarded-Proto} !https
 RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

<files wp-config.php>
order allow,deny
deny from all

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
<IfModule php5_module>
   php_flag asp_tags Off
   php_flag display_errors Off
   php_value max_execution_time 30
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 8M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
   php_value upload_max_filesize 2M
   php_flag zlib.output_compression Off
# END cPanel-generated php ini directives, do not edit

Thank you for any help or ideas you can provide!

  • 1
    since this is a 'migration' i would go over your civicrm.settings.php and Directories and Resources with a fresh eye. it is often a simple typo in there that disrupts things.
    – petednz - fuzion
    Feb 19, 2019 at 19:00

4 Answers 4


Many of these "lost session" issues (which stem mainly from redirect_canonical correcting CiviCRM's malformed URLs) are solved in more recent versions of CiviCRM. All I can really do is suggest you upgrade. FWIW, you can pick through the PRs that deal with URLs here:


However, backporting them to your older version of CiviCRM might be more effort than upgrading.

  • Thanks for the suggestion. Upgraded to CiviCRM 5.13.3. Still get the same result.
    – Dragonfly
    May 28, 2019 at 18:48

I was getting similar errors on a Drupal site - turned out it was timing out during PDF creation for the email receipts, disabling PDF generation resolved the issue for now.

  • Thanks for the suggestion. I tested this and it did not solve the issue.
    – Dragonfly
    May 28, 2019 at 18:49

Checked the server logs.

.htaccess had file permissions set to 0664.

Changed those permissions to 0644, and this problem went away.

  • Hey @Dragonfly, can you give more details of your solution? I'm getting the same error with contributions via PayPal Standard. (Everything else in CiviCRM is working fine.) Which .htaccess file needed to have its permissions changed? Which log file did you check, and what error was reported there? Thanks!
    – Martin_W
    Mar 21, 2020 at 1:14
  • @Martin_W: .htaccess file: It was the .htaccess file in the web root directory. Server logs: I believe I checked the error log(s) that you can bring up in cPanel. I can't be 100% sure, as this was a while ago now. I hope this helps. Let me know if you have any other questions.
    – Dragonfly
    Mar 22, 2020 at 14:09

Hi @dragonfly I am having the same issue and can't seem to get this to resolve


this is what is in my .htaccess at the above path

BEGIN WordPress

The directives (lines) between "BEGIN WordPress" and "END WordPress" are

dynamically generated, and should only be modified via WordPress filters.

Any changes to the directives between these markers will be overwritten.

RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

END WordPress

everything was working fine and now the form wont work. no notable updates to site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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