Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 495
Varuni N R Avatar asked Jul 27 '17 07:07

Varuni N R


1 Answers

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(); 
like image 59
shubham715 Avatar answered Oct 19 '22 09:10

shubham715