CodeIgniter Forums
Protecting modules from users not logged in - 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: Protecting modules from users not logged in (/showthread.php?tid=56853)



Protecting modules from users not logged in - El Forum - 01-25-2013

[eluser]Patrick Reck[/eluser]
Hello!

I'm developing a new website using HMVC patterns. I was wondering how to protect <b>whole</b> modules against users who is not logged in.

As far as I can see, putting the following code in the <i>Controllers constructor</i> seems to work:

Code:
if ($this->session->userdata('is_logged_in') == NULL) { exit; }

Is this a safe approach to keep non-users out?


Protecting modules from users not logged in - El Forum - 01-25-2013

[eluser]Harold Villacorte[/eluser]
Redirect the user.