Hi, everyone.
I'm trying to secure the entire members' area of a website using Ion Auth. I have managed blocking the default page (the index() function) in the following way:
PHP Code:
class Minside extends CI_Controller // Members' area to view orders, change user details and view public profile
{
public function index() // Loads automatically
{
if (!$this->ion_auth->logged_in()) // Check to see if user is logged in
{
echo 'You are not logged in.'; // TODO: Replace with login form
}
else // If user is logged in
{
$data['title'] = 'Min side'; // Set page title
$data['li1class'] = 'active'; // Highlight menu item
$data['li2class'] = '';
$data['li3class'] = '';
$this->load->view('header', $data);
$this->load->view('minside', $data); // Members' area menu
$this->load->view('kjop_og_anmeldelser'); // Default page
$this->load->view('footer');
}
}
public function offentlig_profil() // Public profile
{
$data['title'] = 'Offentlig profil';
$data['li1class'] = '';
$data['li2class'] = 'active';
$data['li3class'] = '';
$this->load->view('header', $data);
$this->load->view('minside', $data);
$this->load->view('offentlig_profil');
$this->load->view('footer');
}
If the user isn't logged in, they can't access example.com/minside. But they can still access example.com/minside/offentlig_profil.
How can i block access to the entire /minside website section without using the same if-statement in all the functions?