6

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

Pankaj Makwana
  • 3,030
  • 6
  • 31
  • 47
Varuni N R
  • 802
  • 3
  • 11
  • 31
  • You can see my previous answer for Reading the salt in Cakephp 3.x, https://stackoverflow.com/questions/19044944/security-salt-value-in-controller/36239832#36239832 – Stephan Jan 11 '18 at 23:24

1 Answers1

11

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(); 
shubham715
  • 3,324
  • 1
  • 17
  • 27