CodeIgniter Forums
Have to be signed in to view page - how to accomplish - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Have to be signed in to view page - how to accomplish (/showthread.php?tid=44739)



Have to be signed in to view page - how to accomplish - El Forum - 08-24-2011

[eluser]Unknown[/eluser]
I would like some pages that users have to be signed in to view.

- I auto-load 'session'
- I manual load a custom helper on the controllers in which I need the user to be signed in

Example:

Sample controller that needs authorization:
Code:
<php
class Account ... {

    function settings()
    {
        $this->load->helper(array('login_authorization'));
    }
}
?&gt;

Sample login_authorization to check if user is signed in, if not redirect
Code:
&lt;?php
    if(isset($this->session->userdata('logged_in')))
    {
        $this->load->helper(array('url'));
        redirect('/signin');
    }
?&gt;

I get an error saying that the session library is not loaded yet

Quote:Message: Undefined property: CI_Loader::$session

Any better way to do this? Or a fix?