I have a few pages that require login, so all controllers that link to these pages start with

//...rest of the code

CheckSession should verify the session is still live, otherwise display a message and stop the execution of the rest of the code in the controller:

function checkSession()
    if (!$this->session->userdata('is_logged_in'))
        //the session has expired!
        $data['main'] = 'confirmation_message';
        $data['title'] = "Session expired";

. I was expecting these instructions to happen in sequence, but I only get a blank page. How can I make sure exit() gets executed only after all views are loaded?


Is there some reason why you need exit() called?

Written by Thorpe Obazee

Accepted Answer

In this case you should not use exit, what you should do if the session is not valid is redirect your app using example:


Best Regards,

Written by Pedro
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki