Prevent access to pages if session is not set |
Is there a way that redirects user to login page if he tries to access a page without logging in.
I have my attempt on doing this but to no avail I failed Code: class Navigation extends CI_Controller Code: class Navigation extends CI_Controller
If you need this to be secure, you should use one of the existing auth libraries. If you don't care about getting hacked and nothing matters, then by all means keep going down that road. It's not that the sessions library is totally hackable, but there's a lot to think about when doing authentication, and it's clear that you've not considered many of the things that would make authentication secure.
Try this:
PHP Code: if (!$this->session->has_userdata('userID')){ |
Welcome Guest, Not a member yet? Register Sign In |