Welcome Guest, Not a member yet? Register   Sign In
A view() to die() for
#1

[eluser]slowgary[/eluser]
Hi all,

I'm tinkering with a basic auth system (I know there are some good ones out there already, but this is just for fun).

My approach is very basic, but for some reason it's not working. Here's my pseudocode:
Code:
class SecureController extends Controller
{
     function SecureController()
     {
          parent::Controller();

          // is_logged_in() returns true/false depending
          if(! $this->is_logged_in()) {
               $this->load->view('login');
               die();
          }
     }
}

class Admin extends SecureController
{
     function index()
     {
          echo 'admin controller';
     }
}

The problem is that the 'login' view is never shown. I know output is buffered in CodeIgniter, so I'm guessing that die() stops the output from being sent to the browser. If I omit die(), however, then 'admin controller' is displayed followed by the contents of the login view.

Is it possible to stop code execution after displaying a view?

Thanks for reading.


Messages In This Thread
A view() to die() for - by El Forum - 08-31-2010, 10:42 AM
A view() to die() for - by El Forum - 08-31-2010, 11:10 AM
A view() to die() for - by El Forum - 08-31-2010, 11:19 AM
A view() to die() for - by El Forum - 09-01-2010, 10:06 AM
A view() to die() for - by El Forum - 09-01-2010, 10:11 AM
A view() to die() for - by El Forum - 09-01-2010, 10:31 AM
A view() to die() for - by El Forum - 09-01-2010, 04:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB