在CodeIgniter php上使用会话+验证时出现问题 [英] Problems using session + validation on CodeIgniter php

查看:45
本文介绍了在CodeIgniter php上使用会话+验证时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究CodeIgniter框架。我没有问题地使用了库会话,获取像这样的数据 $ this-> session-> usserdata('IdUsuario')没关系。

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

但是在使用form_validation之后:

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();
            }
    }

我每次都会得到:


致命错误:调用未定义的方法CI_Session :: usserdata()

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.

会话是在自动加载文件上定义的(它可以正常工作)。 / p>

Session is defined on autoload file (Its working).

推荐答案

尝试一下:

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

代替,

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

这篇关于在CodeIgniter php上使用会话+验证时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆