代码点火器阵列([__ci_last_regenerate] => 1465993659)?>

时间:2016-06-15 12:57:53

标签: codeigniter

我正在学习代码点火器,我正在使用ci.2完成tutuplus d(如何构建cms)的教程.Howeveram使用ci3并且当我尝试获取会话数据时遇到此错误我的登录页面。可能是错误。这是我的代码:

  1. user_m型号
  2. public function login ()
        {
            $user = $this->get_by(array(
                'email' => $this->input->post('email'),
                'password' => $this->hash($this->input->post('password')),
            ), TRUE);
    
            if (count($user)) {
                // Log in user
                $data = array(
                    'name' => $user->name,
                    'email' => $user->email,
                    'id' => $user->id,
                    'loggedin' => TRUE,
                );
                $this->session->set_userdata($data);
                return TRUE;
            }
    
            // If we get to here then login did not succeed
            return FALSE;
        }
    
    1. 我的登录视图
    2. <div class="modal-body">
      <?php print_r($this->session->userdata);?>
      //echoing  my session  data on  my page
      
      1. 这是我父控制器中的代码
      2. class Admin_controller  extends MY_Controller{
        
            function __construct(){
        
                parent :: __construct();
                $this->data['meta_title']='My awesome  cms';
                $this->load->helper('form');
                $this->load->library('form_validation');
                $this->load->library('session');
                $this->load->model('User_M');
        
        1. 这是我的子控制器中的代码
        2.     public function login()
              {
                  $rules =$this->User_M->_rules;
                  $this->form_validation->set_rules($rules);
                  if($this->form_validation->run()==TRUE)
                  {
                      //we can login  and redirect
                      $this->User_M->login();
                  }
          
                  $this->data['subview']='admin/user/login';
                  $this->load->view('admin/_layout_modal',$this->data);
          
              }
          

1 个答案:

答案 0 :(得分:0)

我稍微改变了你的代码

# to my dear love ---------------------------------------------------------

在你的控制器中试试这个代码...然后再回来