<p>For anyone getting this error in version 4. For me the php.ini solution also didn't work. It helped to add a key named:
CRAFT_SECURITY_KEY='YOURKEY'
in the .env file, replace YOURKEY with your actual SECURITY_KEY</p>

CC BY-SA 4.0
2024-06-15T08:25:17.940Z
2024-06-15T08:26:01.870Z
2024-06-15T08:26:01.870Z
Lennie
<p>For a while our Craft CMS webshop show errors in the control panel.
This happens 25%-50% of the requests. Looking in the phperror log a lot of this errors are logged:</p>
<p>[13-Dec-2021 23:00:05 UTC] An Error occurred while handling another error: yii\base\InvalidConfigException: craft\web\Request::cookieValidationKey must be configured with a secret key.</p>
<p>The SECURITY_KEY is set in the .env and also in /config/general.php</p>
<p>It seams like the server can't read or find the .env sometimes.
Earlier i found a topic to change the php variable 'variables_order' EGPCS.
This was not the solution for me.</p>
<p>Anyone some tips?</p>
<p>Craft CMS 3.7.24<br>
PHP 7.4.26 <br>
Hosted on Siteground</p>

<error><env>
craft\web\Request::cookieValidationKey must be configured with a secret key
# craft\web\Request::cookieValidationKey must be configured with a secret key

(Asked by: username_0 on 2021-12-14)

For a while our Craft CMS webshop show errors in the control panel.
This happens 25%-50% of the requests. Looking in the phperror log a lot of this errors are logged:

[13-Dec-2021 23:00:05 UTC] An Error occurred while handling another error: yii\base\InvalidConfigException: craft\web\Request::cookieValidationKey must be configured with a secret key.

The SECURITY\_KEY is set in the .env and also in /config/general.php

It seams like the server can't read or find the .env sometimes.
Earlier i found a topic to change the php variable 'variables\_order' EGPCS.
This was not the solution for me.

Anyone some tips?

Craft CMS 3.7.24  
PHP 7.4.26   
Hosted on Siteground

**Tags:** error, env

---

## 1 answers

### Answer by username_1 on 2024-06-15. Score: 2

For anyone getting this error in version 4. For me the php.ini solution also didn't work. It helped to add a key named:
CRAFT\_SECURITY\_KEY='YOURKEY'
in the .env file, replace YOURKEY with your actual SECURITY\_KEY


---

