Body: <p>I've spent a ton of volunteer hours getting CiviCRM 5.37.2 set up for this new non-profit on a WordPress site.  Got Sparkpost hooked up to CiviMail. Tested the Unsubscribe/Opt-Out link in the footer of an email and it fails with 'Could not find a valid session key'. All the other links in the email Header/Footer work. The same version of Civi works fine under DreamHost, but not Cloudways.  Cloudways support spent a lot of time with me, checked the PHP and Apache logs, but couldn't see any error. They had me add a line to my PHP settings to save the session path, but the problem persists. <strong>I really hope y'all can point me in the right direction!</strong> Here are some screen shots:</p>
  <p>Test email:<a href="https://i.sstatic.net/26rej.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/26rej.png" alt="Test Email" /></a>
  <a href="https://votersfirstwi.org/civicrm/mailing/optout/?reset=1&amp;jid=18&amp;qid=19&amp;h=1c6ac906312244a3" rel="nofollow noreferrer">https://votersfirstwi.org/civicrm/mailing/optout/?reset=1&amp;jid=18&amp;qid=19&amp;h=1c6ac906312244a3</a></p>
  <p>Opt-Out Screen: <a href="https://i.sstatic.net/fnMr7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fnMr7.png" alt="Opt-Out screen" /></a>
  <a href="https://votersfirstwi.org/civicrm/mailing/optout/" rel="nofollow noreferrer">https://votersfirstwi.org/civicrm/mailing/optout/</a></p>
  <p>Error Message: <a href="https://i.sstatic.net/X9SBT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/X9SBT.png" alt="Error Message" /></a></p>
  <p><strong>The Civi Log says this:</strong></p>
  <pre><code>$Fatal Error Details = array:3 [
    &quot;message&quot; =&gt; &quot;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.&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;Error type: Could not find a valid session key.&quot;
    &quot;code&quot; =&gt; null
    &quot;exception&quot; =&gt; CRM_Core_Exception {#6809
      -errorData: array:1 [
        &quot;error_code&quot; =&gt; 0
      ]
      #cause: null
      -_trace: null
      #message: &quot;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.&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;Error type: Could not find a valid session key.&quot;
      #code: 0
      #file: &quot;/home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php&quot;
      #line: 829
      trace: {
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php:829 {
          â€º   $msg = ts(&quot;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.&quot;) . '&lt;br /&gt;&lt;br /&gt;' . ts('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.') . '&lt;br /&gt;&lt;br /&gt;' . ts('Error type: Could not find a valid session key.');
          â€º   throw new CRM_Core_Exception($msg);
          â€º }
        }
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php:824 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php:308 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php:190 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller/Simple.php:49 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Wrapper.php:62 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:286 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:69 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:36 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm.php:1172 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/includes/civicrm.basepage.php:354 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/class-wp-hook.php:292 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/class-wp-hook.php:316 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/plugin.php:551 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/class-wp.php:763 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/functions.php:1291 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-blog-header.php:16 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/index.php:17 { â€¦}
      }
    }
  ]
  
  
  Aug 13 10:49:09  [debug] $backTrace = #0 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(433): CRM_Core_Error::backtrace(&quot;backTrace&quot;, TRUE)
  #1 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(39): CRM_Core_Error::handleUnhandledException(Object(CRM_Core_Exception))
  #2 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm.php(1172): CRM_Core_Invoke::invoke((Array:3))
  #3 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/includes/civicrm.basepage.php(354): CiviCRM_For_WordPress-&gt;invoke()
  #4 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/class-wp-hook.php(292): CiviCRM_For_WordPress_Basepage-&gt;basepage_handler(Object(WP))
  #5 /home/xxxxxxx.cloudwaysapps.com/xxxxxxx/public_html/wp-includes/class-wp-hook.php(316): WP_Hook-&gt;apply_filters(&quot;&quot;, (Array:1))
  #6 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/plugin.php(551): WP_Hook-&gt;do_action((Array:1))
  #7 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/class-wp.php(763): do_action_ref_array(&quot;wp&quot;, (Array:1))
  #8 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/functions.php(1291): WP-&gt;main(&quot;&quot;)
  #9 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-blog-header.php(16): wp()
  #10 /home/xxxxxx.cloudwaysapps.com/xxxxxxx/public_html/index.php(17): require(&quot;/home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-blog-header.php&quot;)
  #11 {main}
  </code></pre>
  <p>I found two seemly relevant threads here in StackExchange:</p>
  <p><a href="https://civicrm.stackexchange.com/questions/7002/could-not-find-a-valid-session-key-when-submitting-opt-out-and-unsubscribe-forms">Could not find a valid session key when submitting opt out and unsubscribe forms</a></p>
  <p><a href="https://civicrm.stackexchange.com/questions/2422/could-not-find-a-valid-session-key-unable-to-save-any-admin-forms?rq=1">&quot;Could not find a valid session key.&quot; Unable to save any admin forms</a></p>
  <p><strong>Please help...thanks!!!</strong></p>
  <p><strong>UPDATE</strong>: CiviCRM is causing WordPress Site Health Critical Errors (they go away when CiviCRM is deactivated). <strong>What the heck is going on here?</strong>
  <a href="https://i.sstatic.net/ZoDA1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZoDA1.png" alt="enter image description here" /></a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-13T20:26:27.297Z
Comments.Text: may not be relevant, and it is possible it is in the above, but what version of php are you using?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-14T03:28:39.280Z
Comments.Text: Pertinent question...7.3...thanks for looking...and I've cleared my cache lots of times...
Comments.UserDisplayName: jimcrist
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-14T14:32:43.410Z
Comments.Text: Ugh...I upgraded to 7.4 PHP, but the error persists.  Is this a bug in CiviCRM?  I'm on WordPress 5.7.2.
Comments.UserDisplayName: jimcrist
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-14T15:27:22.207Z
Comments.Text: I updated my question to include the URLs that occur during the opt-out attempt. Please help...
Comments.UserDisplayName: jimcrist
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-14T19:13:59.710Z
Comments.Text: if you have not already, you may want to try https://chat.civicrm.org/civicrm/channels/wordpress
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-17T02:04:56.187Z
Comments.Text: Good news sort of...I upgraded to Civi 5.40.1 and the session key error went away!  So CiviMail is communicating with Sparkpost to send the email.  I can click unsubscribe, the opt-out screen appears, I enter the email address, click opt-out and it fails to display the opt-out confirmation screen...ugh!  The URL does not change, but it clears out the email address field.  No confirmation!!  The opt-out does process in the CiviCRM database, so that's good.  How do I get the confirmation screen to display???
Comments.UserDisplayName: jimcrist
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-17T02:11:25.450Z
Comments.Text: The opt-out message is Enabled. No errors appear in ConfigAndLog.
Comments.UserDisplayName: jimcrist
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-17T03:28:35.370Z
Comments.Text: Just realized that it is sending opt-out confirmation emails.  I guess this is the way it works when Sparkpost is involved???
Comments.UserDisplayName: jimcrist
Tags: <wordpress><civimail><opt-out>
Title: Opt Out fails with a 'Could not find a valid session key'
ThreadText: # Opt Out fails with a 'Could not find a valid session key'
  
  (Asked by: username_0 on 2021-08-13)
  
  I've spent a ton of volunteer hours getting CiviCRM 5.37.2 set up for this new non-profit on a WordPress site. Got Sparkpost hooked up to CiviMail. Tested the Unsubscribe/Opt-Out link in the footer of an email and it fails with 'Could not find a valid session key'. All the other links in the email Header/Footer work. The same version of Civi works fine under DreamHost, but not Cloudways. Cloudways support spent a lot of time with me, checked the PHP and Apache logs, but couldn't see any error. They had me add a line to my PHP settings to save the session path, but the problem persists. **I really hope y'all can point me in the right direction!** Here are some screen shots:
  
  Test email:[![Test Email](https://i.sstatic.net/26rej.png)](https://i.sstatic.net/26rej.png)
  <https://votersfirstwi.org/civicrm/mailing/optout/?reset=1&jid=18&qid=19&h=1c6ac906312244a3>
  
  Opt-Out Screen: [![Opt-Out screen](https://i.sstatic.net/fnMr7.png)](https://i.sstatic.net/fnMr7.png)
  <https://votersfirstwi.org/civicrm/mailing/optout/>
  
  Error Message: [![Error Message](https://i.sstatic.net/X9SBT.png)](https://i.sstatic.net/X9SBT.png)
  
  **The Civi Log says this:**
  
  ```
  $Fatal Error Details = array:3 [
    "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" => null
    "exception" => CRM_Core_Exception {#6809
      -errorData: array:1 [
        "error_code" => 0
      ]
      #cause: null
      -_trace: null
      #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: 0
      #file: "/home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php"
      #line: 829
      trace: {
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php:829 {
          â€º   $msg = ts("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 />' . ts('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 />' . ts('Error type: Could not find a valid session key.');
          â€º   throw new CRM_Core_Exception($msg);
          â€º }
        }
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php:824 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php:308 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php:190 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller/Simple.php:49 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Wrapper.php:62 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:286 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:69 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:36 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm.php:1172 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/includes/civicrm.basepage.php:354 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/class-wp-hook.php:292 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/class-wp-hook.php:316 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/plugin.php:551 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/class-wp.php:763 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/functions.php:1291 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-blog-header.php:16 { â€¦}
        /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/index.php:17 { â€¦}
      }
    }
  ]
  
  Aug 13 10:49:09  [debug] $backTrace = #0 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(433): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(39): CRM_Core_Error::handleUnhandledException(Object(CRM_Core_Exception))
  #2 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/civicrm.php(1172): CRM_Core_Invoke::invoke((Array:3))
  #3 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-content/plugins/civicrm/includes/civicrm.basepage.php(354): CiviCRM_For_WordPress->invoke()
  #4 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/class-wp-hook.php(292): CiviCRM_For_WordPress_Basepage->basepage_handler(Object(WP))
  #5 /home/xxxxxxx.cloudwaysapps.com/xxxxxxx/public_html/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters("", (Array:1))
  #6 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/plugin.php(551): WP_Hook->do_action((Array:1))
  #7 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/class-wp.php(763): do_action_ref_array("wp", (Array:1))
  #8 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-includes/functions.php(1291): WP->main("")
  #9 /home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-blog-header.php(16): wp()
  #10 /home/xxxxxx.cloudwaysapps.com/xxxxxxx/public_html/index.php(17): require("/home/xxxxxx.cloudwaysapps.com/xxxxxx/public_html/wp-blog-header.php")
  #11 {main}
  
  ```
  
  I found two seemly relevant threads here in StackExchange:
  
  [Could not find a valid session key when submitting opt out and unsubscribe forms](https://civicrm.stackexchange.com/questions/7002/could-not-find-a-valid-session-key-when-submitting-opt-out-and-unsubscribe-forms)
  
  ["Could not find a valid session key." Unable to save any admin forms](https://civicrm.stackexchange.com/questions/2422/could-not-find-a-valid-session-key-unable-to-save-any-admin-forms?rq=1)
  
  **Please help...thanks!!!**
  
  **UPDATE**: CiviCRM is causing WordPress Site Health Critical Errors (they go away when CiviCRM is deactivated). **What the heck is going on here?**
  [![enter image description here](https://i.sstatic.net/ZoDA1.png)](https://i.sstatic.net/ZoDA1.png)
  
  **Tags:** wordpress, civimail, opt-out
  
  > **Comments:**
  > **username_1**: may not be relevant, and it is possible it is in the above, but what version of php are you using?  
  > **username_0**: Pertinent question...7.3...thanks for looking...and I've cleared my cache lots of times...  
  > **username_0**: Ugh...I upgraded to 7.4 PHP, but the error persists.  Is this a bug in CiviCRM?  I'm on WordPress 5.7.2.  
  > **username_0**: I updated my question to include the URLs that occur during the opt-out attempt. Please help...  
  > **username_1**: if you have not already, you may want to try https://chat.civicrm.org/civicrm/channels/wordpress  
  > **username_0**: Good news sort of...I upgraded to Civi 5.40.1 and the session key error went away!  So CiviMail is communicating with Sparkpost to send the email.  I can click unsubscribe, the opt-out screen appears, I enter the email address, click opt-out and it fails to display the opt-out confirmation screen...ugh!  The URL does not change, but it clears out the email address field.  No confirmation!!  The opt-out does process in the CiviCRM database, so that's good.  How do I get the confirmation screen to display???  
  > **username_0**: The opt-out message is Enabled. No errors appear in ConfigAndLog.  
  > **username_0**: Just realized that it is sending opt-out confirmation emails.  I guess this is the way it works when Sparkpost is involved???  
  
  ---
  
  ## 0 answers
  
  