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
        $data['title'] = "Please Login";
        $data['content'] = 'login_view';
        $this->load->view('templates/login/template', $data);

Please help me solve this, thanks

Member Avatar for diafol

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.