I am trying to save api authorization key (sensitive information) in an environment variable. I used fastcgi_param inside location ~ .php$ in Nginx configuration. I am calling this variable inside function.php file in wordpress to use the api. Is this secure or should i use phpdotenv php package and create .env file to define the variable. Thanks
Nginx:
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param API_AUTH 'xxxxxxxxxxxxxxxxxxxx';
}
Function.php
$auth = $_SERVER['API_AUTH'];
New contributor
Faizan Ahmed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.