CodeIgniter Forums
Where Store Admin Information? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Where Store Admin Information? (/showthread.php?tid=65096)



Where Store Admin Information? - pb.sajjad - 04-28-2016

Hi to all developers...
I'm developing a web application. In this app, There is one Admin and maybe, maybe in the future there is another (with restricted controls). My question is: Should I create a table for admin or save the necessary admin info in a file (xml file or...)? Please mention to different aspects (like security or...) that I will encounter with these.
thanks a lot...


RE: Where Store Admin Information? - CINewb - 04-28-2016

Yes, have a database table called "users" which would have fields like "username", "password", "last_login_date"

You can then query this table when the admin user wants to login.

Having the details in a database table means you can have more than one user, and in the future you can include things like permissions, logging the number of failed login attempts, etc


RE: Where Store Admin Information? - Wouter60 - 04-29-2016

I recommend an authentication library for CI, like Ion Auth from Ben Edmunds. It comes with tables for users, groups and users_groups. And a lot of powerful functions in it's library.
Example:
PHP Code:
$this->ion_auth->is_admin(); 
This will return a boolean (true or false) to check if the current user is a member of the group "admin".

Also, you can check if a user is member of any other group, like this:
PHP Code:
$employee $this->ion_auth->in_group('employee');