CodeIgniter Forums

Full Version: How to create Admin Section in CodeIgniter Project?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all, 

I have created a simple project in CI. Now I want to create users and Admins. How to create an area only admin can login and modify data? Should I create an ADMIN Folder in APPLICATION folder and install another CI in it?
Quote:Should I create an ADMIN Folder in APPLICATION folder and install another CI in it?

I certainly wouldn't do that. You can create an admin controller, containing the functions for modifying data (in your database).
Make sure you have a login procedure that forces you to log in when you access the admin controller. Let the constructor of the admin controller check if you're logged in as admin or not.
You can develop your own authentication system, but you really don't need to. There are various authentication libraries for CI, like Ion_auth and Community_auth.
I just create an Admin Controller and view folders.

In all of the Admin Controllers do a check to make sure that the user is an Admin.
For anyone else wanting to do this, I believe you don't have to have a single admin controller.

You can just make a sub-directory inside "controllers" called "admin" and then place individual controllers in there.

For example:

\application\controllers\admin\Sales.php
\application\controllers\admin\Customers.php
(03-24-2017, 02:06 AM)Wouter60 Wrote: [ -> ]You can develop your own authentication system, but you really don't need to. There are various authentication libraries for CI, like Ion_auth and Community_auth.

+1
(03-23-2017, 10:21 PM)Shivafeb17 Wrote: [ -> ]Hi all, 

I have created a simple project in CI. Now I want to create users and Admins. How to create an area only admin can login and modify data? Should I create an ADMIN Folder in APPLICATION folder and install another CI in it?

Hi...
I think it's depends on you, your need and your project scale. With CI you could create an admin folder in controller and put your admin controllers in it, and for view, create an specific folder in views folder, if you want to have a different view for admin section. Another option is separate installation for main (users) and admin (you). In this case, you must consider that there are some common codes between these two apps installation that cause you do more and more copy/paste.

You decide about these...
Good Luck.
For a relatively big project a separate admin application is more suitable. Copy/paste code could be avoided, but this means that you have to rework CodeIgniter for supporting shared code.

http://iridadesign.com/starter-public-edition-4/www/
http://iridadesign.com/starter-public-ed.../www/admin