English 中文(简体)
• 如何使用密码用户数据
原标题:How to use $this->session->set_userdata in codeigniter

我与 CI有过一些可兑换之处,即使用thi和gt;拥有和开发;用户数据。

主计长

 public function check_login()
{
    $email    = $this->input->post( username_email );
    $password = $this->input->post( passwords );
    $password_encrypt = sha1(md5($password));

    $query = $this->model->check_login($email,$password_encrypt);
    if( $query->num_rows() > 0 )
    {
        $row = $query->row(1);
        $data = array(
           email            => $row->email,
           level_id         => $row->level_id,
           id_subunit       => $row->id_subunit,
        );
        $this->session->set_userdata($data);
        return TRUE;
    }
    else{
        return FALSE;
    }
}

示范法

function check_login($email,$password_encrypt)
{
    $db = $this->load->database( default ,TRUE);
    $where_email = array( email  => $email,  password  => $password_encrypt);

    $db->where($where_email);
    $query = $db->get( admin ,1);

    return $query;
}

我试图在这里获得会议数据。

public function home()
{
    $data[ level ] = $this->session->userdata( level_id );
    $data[ email ] = $this->session->userdata( email );
    $data[ id_subunit ] = $this->session->userdata( id_subunit );

    if($data[ level ] == 1){
        redirect( admin );
    }
    else if($data[ level ] == 2){
        redirect( kuesioner/submited ); 
    }
    /*else{
         redirect( sub_unit/home );
    }*/
}

我的问题是,从届会的阵列中获取电子邮件和等级。

如何解决这一问题?

问题回答

Load session Library in You controller or in config/autoload. php档案。

$this->load->library( session );

然后确定会议数据。

$this->session->set_userdata($data);

Maybe comma

$data = array(
   email            => $row->email,
   level_id         => $row->level_id,
   id_subunit       => $row->id_subunit
);




相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签