Creating Multiuser Login With CodeIgniter

Creating a Multiuser Login Using Codeigniter – In this tutorial I will explain how to create a multiuser login session with CodeIgniter, without saying much, let’s find out how to create a multiuser login session with CodeIgniter?

First create a database and a table for the user, here I create a codeigniter database and a login_session table with the following sql:

Untitled

— Database: codeigniter


— Table structure for table login_session

CREATE TABLE IF NOT EXISTS login_session (
uid bigint(20) NOT NULL,
username varchar(30) NOT NULL,
password varchar(255) NOT NULL,
level enum(‘admin’,’member’) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

— Dumping data for table login_session

INSERT INTO login_session (uid, username, password, level) VALUES
(1, ‘admin’, ‘21232f297a57a5a743894a0e4a801fc3’, ‘admin’),
(2, ‘member’, ‘aa08769cdcb26674c6706093503ff0a3’, ‘member’);

— Indexes for dumped tables

CodeIgniter Database
Note: the password uses the database so when you create a new user it is expected to use md5 for the password.

After finished creating the database we will create a new folder in your htdocts folder here I use xampp create a folder with the name login_session then create a new Controller with the name auth.php :

if you follow all the tutorials on the structure of the folder and files in the codeigniter folder it will be like this, I marked a red line which means the file that we created in the tutorial creates a multiuser login session with this codeigniter

1

Open your creation and see if it is correct a simple login form will appear with the Log In button. Enter the username and password that is in the database then click the login button, if the admin who enters will be directed to the admin page, if the member will be directed to the member page