Where and how are values from .env defined as PHP constants


I try to set the cookie domain for my wordpress bedrock environment with sage theme. But it seems, that wordpress to not recognize the change:

I added


to my .env file.

The wordpress behaviour on cookies did not change, so I output some vars with

echo "WP_SITEURL" . WP_SITEURL . "<br />";
echo "COOKIE_DOMAIN" . COOKIE_DOMAIN . "<br />";

WP_SITEURL was set to the value I gave it in .env file. “COOKIE_DOMAIN” was just empty. For COOKIEPATH it`s the same.

Is there a list, which values are accepted in .env file and than defined in PHP? What else could be wrong?

Thank you!

1 Like

I’ve actually done the same thing, but an environment variable is not the same thing as a constant. See here: https://github.com/roots/bedrock/blob/master/config/application.php#L42-L45

You still need to define the constant in one of your PHP files with define('COOKIE_DOMAIN', getenv('COOKIE_DOMAIN'));


Ok, thank you. I thought, I could change every wordpress option in the .env file. Is documented, which wordpress options I can change in the .env file?

Search for getenv in config/application.php

1 Like