Waseem Bashir
Waseem Bashir

Reputation: 678

codeigniter encryption key to save in external file and set in encrypt library.

Hi i need the codeigniter encryption library encryption key to set form external file because i dont want this to set in config.php file because of security.

 $config['encryption_key'] = 'my_key';

Upvotes: 0

Views: 358

Answers (2)

mith
mith

Reputation: 1700

You can use Loading custom config file :-

After create custom config file we need to load it get it’s items. for load custom config we have two ways.

  1. Manual loading :- we can manual load config file in controller/model like

     $this->config->load('file_name'); //or use custom_config instead of file_name
    

where “file_name” is your custom config file name without .php extension.

  1. Autoloading :- for auto load config file go to “application/config/autoload.php” and add code in $autoload[‘config’]

    $autoload['config'] = array('config_custom'); //where config_custom is your file name.
    

Upvotes: 1

Hikmat Sijapati
Hikmat Sijapati

Reputation: 6994

Make a new config file application/config/config1.php.with

$config['encryption_key'] = 'my_key';

Now load it form application/config/autoload.php as below:

$autoload['config'] = array('config1');

Upvotes: 0

Related Questions