login password verification issue solved in codeinget

<?php
if($this->input->post('loginSubmit')){
        $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
        $this->form_validation->set_rules('password', 'password', 'required');
        if ($this->form_validation->run() == true) {
            $con['returnType'] = 'single';
            $con['conditions'] = array(
                'email'=>$this->input->post('email'),
                'status' => '1'
            );

            $checkLogin = $this->user->getRows($con); // assumes 'password' field is also returned..
            if(password_verify($this->input->post('password'), $checkLogin['password']){
                $this->session->set_userdata('isUserLoggedIn',TRUE);
                $this->session->set_userdata('userId',$checkLogin['id']);
                redirect('users/account');
            }else{
                $data['error_msg'] = 'Wrong email or password, please try again.';
            }
        }
    }
?>

Reference : https://stackoverflow.com/questions/50443246/how-to-use-password-hash-for-codeigniter

Comments

Popular posts from this blog

dynamic create multiple ckeditor onclick event using jquery

Fatal error: Can't use method return value in write context in ci

online visitor counter