Welcome Guest, Not a member yet? Register   Sign In
User Auth with Private Function
#1

[eluser]johnmchilton[/eluser]
My login function sets a session userdata variable called "logged_in". At the beginning of each other function, the value of that is checked. This was a terrible solution, because it meant that all of the function's code had to be in an else {} block:
Code:
function index() {
  if(!$this->session->userdata('logged_in') {
    $this->load->view('login');
  } else {
    //what this function is meant to do, ending with...
    $this->load->view('main');
  }
}
So I decided to move that to a private function, which I'm calling _init(). Here is the basic structure of how I want it to work:
Code:
function _init($check=true) {
  $data["header"] = "Welcome ...";
  $data["title"] = "Site Title ...";

  if($check) {
    if(!$this->session->userdata('logged_in')) {
      $this->load->view('login');
    }
  }
}


function index() {
  $this->_init();

  $this->load->view('main');
}
However, loading the login view doesn't stop execution. I don't know how to get the login part to stop the rest of its caller...does anyone know what I'm trying to say or how to help? Thanks!


Messages In This Thread
User Auth with Private Function - by El Forum - 07-01-2007, 06:07 PM
User Auth with Private Function - by El Forum - 07-02-2007, 04:57 AM
User Auth with Private Function - by El Forum - 07-02-2007, 05:28 AM
User Auth with Private Function - by El Forum - 07-02-2007, 09:58 AM
User Auth with Private Function - by El Forum - 07-05-2007, 11:33 PM
User Auth with Private Function - by El Forum - 07-09-2007, 05:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB