• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create Admin Section in CodeIgniter Project?

#1
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?
Reply

#2
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.
Reply

#3
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.
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply

#4
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
Reply

#5
(03-24-2017, 03: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
Reply

#6
(03-23-2017, 11: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.
Reply

#7
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
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
2 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.