Varuni N R Varuni N R - 1 year ago 75
PHP Question

fetch security salt in cakephp 3

I read documents and I am not able to get it how to get

Security.salt
value from
app.php
in
Cakephp 3
. I am trying to get it like this

$salt = Configure::read('Security.salt');


Importing following libraries

use Cake\Core\Configure;
use Cake\Core\Configure\Engine\PhpConfig;


Kindly help.

Cakephp version is 3.4

Answer Source

Configure::Read('Security.salt') will return a blank value in cakephp 3.x before cakephp 3 version it worked.

In-order to read the salt from the configuration file you'll need to include the Security namespace:

use Cake\Utility\Security;

And you can retrieve the value of the salt using:

Security::salt()

Example-

 echo Security::salt(); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download