So we have our controller, but we don’t have any users or any way to check a user. We also need to configure CodeIgniter to use sessions so that you don’t have to login to every single page you visit. To do this we will need to edit the config files in the application/config directory.
So first off we will add the required modules to the autload config file. Open up the file autoload.php and add to the autoload array.
$autoload['libraries'] = array('database', 'session');
The second is the helpers. The only one we need to load here is the URL helper as this give us access to soe useful function regarding loading reources in our pages.
$autoload['helpers'] = array('url');
That’s it for the autoload file. We now need to edit the main config file, config.php. We only need to add one thing here, the encryption key. If you google “codeigniter encryption key” you should be able to find a generator online somewhere. Copy and paste the key next to where it reads (we don’t need to use this at the moment but it might come in handy later) $config[‘encryption_key’].
Next, we need to edit the database file. This file tells CodeIgniter how to connect to our database. Scroll to the bottom of the file and add in the hostname, username, password and database. (If you want to create a dedicated user, not root, then head over here). Close and save the file.
Lastly, we need to edit the routes file. This file contains the default controller and function for our site. So change the default controller to this:
$route['default_controller'] = 'login';
That’s it. All the configuration is done and now we can actually write our model and create some users.