CodeIgniter Forums
Application with different type of user - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Application with different type of user (/showthread.php?tid=57495)



Application with different type of user - El Forum - 03-19-2013

[eluser]foysal[/eluser]
I am working on a project. Their are 2 types of user. 1. Admin, 2. User. http://localhost/my_app/index.php/welcome is URL for normal user login. After logged in a normal user will come in this URL. http://localhost/my_app/index.php/administrator is URL for admin login. After logged in an Admin will come in this URL. If I logged in as user, then try to browse using the URL of Admin then application showing Admin is also logged in.


How can I solve this problem ?? Have you any idea ??

Thanks

Foysal


Application with different type of user - El Forum - 03-19-2013

[eluser]NikosV[/eluser]
checking if user is logged is not enought. you should also check his user group on every cocntroller and display the appropriate views.


Application with different type of user - El Forum - 03-19-2013

[eluser]TheFuzzy0ne[/eluser]
You can do this by creating a single controller for each user group, and extending it.

http://philsturgeon.co.uk/blog/2010/02/CodeIgniter-base-Classes-Keeping-it-DRY


Application with different type of user - El Forum - 03-19-2013

[eluser]foysal[/eluser]
I am getting this error in this case.


A PHP Error was encountered

Severity: Notice

Message: Undefined property: Users::$session

Filename: controllers/users.php

Line Number: 17

Fatal error: Call to a member function userdata() on a non-object in E:\xampp\htdocs\my_app\application\controllers\users.php on line 17



I auto loaded the session library in this way

$autoload['libraries'] = array('session');

Thanks




Application with different type of user - El Forum - 03-19-2013

[eluser]NikosV[/eluser]
You should post what exactly is number 17 of the controllers/users.php



Application with different type of user - El Forum - 03-19-2013

[eluser]TheFuzzy0ne[/eluser]
You're most likely not extending the correct base controller, or you're not calling the parent constuctor.

Guessing can be fun, but if you post your code it might save us some time.