0

Im working on CodeIgniter Framework. I used the library session without problems, getting data like this $this->session->usserdata('IdUsuario') this is ok.

But after uses form_validation :

  public function verify_password()
    {
      $this->load->library('form_validation');

            $this->form_validation->set_rules('Password', 'Contraseña', 'required|trim|callback_correct_password');
            $this->form_validation->set_rules('Password1', 'Nueva ontraseña', 'required|trim');
            $this->form_validation->set_rules('Password2', 'Repetir contraseña', 'required|trim|matches[Password1]');

            $this->form_validation->set_message('correct_password', 'Contraseña incorrecta');
            $this->form_validation->set_message('required', 'El campo %s es obligatorio.');
            $this->form_validation->set_message('matches', 'El campo %s no es igual que el campo %s.');
            if ($this->form_validation->run() == FALSE) {
                $this->edit_password();
            } else {
                   $this->Opciones_model->save_password($this->input->post('Password'), $this->session->usserdata('IdUsuario'));
                   $this->index();
            }
    }

I get every time:

Fatal error: Call to undefined method CI_Session::usserdata()

This happens only when I use validation + session, I tried few differents tries but always the same error.

Session is defined on autoload file (Its working).

4
  • 3
    Can you post your constructor as well as save password method? Commented Dec 19, 2017 at 20:33
  • 1
    usserdata should be userdata but that's besides the point. Where is your save password function? In this controller? Commented Dec 20, 2017 at 0:48
  • sorry I posted wrong code ( it was test ) , now is correct, save_password is model function. the error is : Call to undefined method CI_Session::usserdata() Commented Dec 20, 2017 at 8:47
  • Read my comment again. You spelled it wrong Commented Dec 22, 2017 at 1:54

1 Answer 1

1

Try this:

 $this->session->userdata('IdUsuario')

Instead off,

 $this->session->usserdata('IdUsuario') 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.