0

Hi i am currently building a admin section for my website but i am stuck at a certain point, right now my user authentication is working and my form validation is working great, when i log in as admin i want it to display the admin dash and when a user logs in i want to show the dash but with diffrent links.

So what i want to do now is just modify my current login function to accommodate the diffrent roles here is my login function:

    public function do_login()
    {
        $data['error'] = 0;
        if ($_POST) {
            $username = $this->security->xss_clean($this->input->post('username', true));
            $password = $this->security->xss_clean($this->input->post('password', true));
            $user = $this->Login_m->verify($username, $password);
            if (!$user) {
                $data['error'] = 1;
            } else {
                $data = array(
                    'userID' => $user['userID'],
                    'username' => $user['username'],
                    'first' => $user['firstName'],
                    'last' => $user['lastName'],
                    'logged_in' => true
                );
                $this->session->set_userdata($data);
                redirect(base_url().'admin');
            }
        }
        $data['title'] = "Please Login";
        $data['content'] = 'login_view';
        $this->load->view('templates/login/template', $data);
    }

Please help me solve this, thanks

2
Contributors
1
Reply
17
Views
2 Years
Discussion Span
Last Post by diafol
0

Not sure why you need logged in in a session array. If user id present then obviously logged in. Just store userlevel From db in session array too. Am assuming you have this info in db somewhere. Then when you prepare a page (view) you can choose what to include and what not to include

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.