[eluser]brianatlarge[/eluser]
[quote author="nagata" date="1341513549"]
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin extends CI_Controller {
public function __construct()
{
parent::__construct();
$user_email = $this->session->userdata('user_email');
if(!empty($user_email)) {
//logged in, do nothing, let the index load safely...
} else {
redirect("admin/login");
}
}
public function index()
{
$this->load->view('admin/home');
}
public function login()
{
$this->load->view('admin/login');
}
}
Its just Index is an initial page loaded if there is no function defined when u are going somewhere
ex: u have admin panel controller,
if u visit admin it will load by default the index()
if there was a function given it will then admin/(function)
...
u see...
it should do anything when user is logged in, if he isnt then just redirect him to login page...
[/quote]
Hmm... when I do this, it just loops the redirect part.