我正在学习代码点火器,我正在使用ci.2完成tutuplus d(如何构建cms)的教程.Howeveram使用ci3并且当我尝试获取会话数据时遇到此错误我的登录页面。可能是错误。这是我的代码:
user_m
型号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;
}
<div class="modal-body">
<?php print_r($this->session->userdata);?>
//echoing my session data on my page
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');
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);
}
答案 0 :(得分:0)
我稍微改变了你的代码
# to my dear love ---------------------------------------------------------
在你的控制器中试试这个代码...然后再回来