CodeIgniter Forums
Is this correct way... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Is this correct way... (/thread-1799.html)



Is this correct way... - El Forum - 06-27-2007

[eluser]mk3[/eluser]
I found solution. how to include in every page login form, but do not really know if it is correct. the method I used is I auto loaded library. and the library constructor is doing the following:
Code:
class Authorize {
    
    //constructor    
    function Authorize(){
        $this->CI =& get_instance();
        $this->CI->load->library('MySmarty');
        $this->CI->load->library('session');
        $this->CI->mysmarty->assign('login_errors', null);
        $this->CI->mysmarty->assign('user', $this->CI->session->userdata('user_data'));
        $this->CI->mysmarty->assign('logged_in', $this->CI->session->userdata('logged_in'));
        if (isset( $_POST['submit']) && $_POST['submit'] == 'Login'){
            $this->login();    
        }
    }

So when login form is submitted authorize library calls function which then processes login.

What it is interesting for me am I doing the right way. It seems OK for me, but I believe there are/can be some issues why this cannot be done.

Also would be nice to hear suggestions and critics.