CodeIgniter Forums
Howto include Login Site - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Howto include Login Site (/showthread.php?tid=36221)



Howto include Login Site - El Forum - 11-25-2010

[eluser]toki[/eluser]
Hi,

I build a login controller, which uses a login model and shows a login view.
Now I have other functions (controllers), which shall be only available for logged in users.
When the other controller recognizes that the user is not logged in, it shall append the login form at the end of the view.

How can i do this without redundancy of code?

Thank you!

toki


Howto include Login Site - El Forum - 11-25-2010

[eluser]Abdul Malik Ikhsan[/eluser]
I think you can create your own base controller like MY_Controller. then, you create default "doing" function like showloginform() in constructor. and you can extends in your app using extends MY_Controller simply like parent::MYController();

for detail, you can read user_guide Smile


Howto include Login Site - El Forum - 11-25-2010

[eluser]cryogenix[/eluser]
this post of mine might help you: http://ellislab.com/forums/viewreply/773561/

that post example was using ION_Auth as an example but I'm pretty much sure it's very adaptable to your own auth implementation.

cheers,
hope it helps.
my 2 cents worth Wink


Howto include Login Site - El Forum - 11-26-2010

[eluser]toki[/eluser]
Thanks a lot for both answers. That helps.