Problems using session + validation on CodeIgniter php

回眸只為那壹抹淺笑 提交于 2019-12-23 04:47:15

问题


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).


回答1:


Try this:

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

Instead off,

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


来源:https://stackoverflow.com/questions/47894677/problems-using-session-validation-on-codeigniter-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!