CodeIgniter doesn’t come with a user authentication system out of the box (urgh, that phrase), but nevertheless it doesn’t. If you want to manage users and sessions, there are several options open to you. You can install an auth Spark, or you can develop your own solution—which is what we will do here.
One of the irritations I have with other “third-party” plugins (whatever their purpose) is that the code is almost always difficult, making maintenance and integration difficult. This authentication system is as simple as I can make it, and hopefully, it will be easy for you to adapt and extend it for your purposes.
The authentication system provided in this tutorial will allow you to create and manage users, password resets, user e-mail notifications, user logins, and so on.
In this tutorial, we will cover the following topics:
- Design and wireframes
- Creating the database
- Creating the models
- Creating the views
- Creating the controllers
- Putting it all together
To create this app, we will create five controllers: one to handle signing in to sessions, one to handle admin functions (CRUD operations), one for user password management, one to allow a user to register, and one to offer functionality to a user once they are logged in.
We’ll also create a language file to store text, allowing you to have multiple language support should that be required.
We will make amends to the
config.php file to allow for encryption support necessary for sessions and password support.
We’ll create all the necessary view files and even a CSS file to help Bootstrap with some of the views.
So without further ado, let’s get on with it.