如何在代码点火器中设置会话并在方法中访问它?



我想在我的控制器中设置会话并访问方法中的会话数据。 谁能告诉我实现它的方法?下面是我的代码块

if ($data['result'] = $this->Webmanager_model->admin_login($credential)) {
foreach ($data['result'] as $val) {
$credentials = array(
'adminid' => $val->admin_id,
'name' => $val->name,
'username' => $val->username);
}
$this->session->adminid = $val->admin_id;
$this->session->name = $val->name;
$this->session->username = $val->username;
$this->load->view('dashboard1');
} else {
echo "access denied";
}

这样 IAM 设置会话,但它在下一个方法上显示空。

if($data['result'] = $this->Webmanager_model->admin_login($credential))
{
foreach ($data['result'] as $val) 
{
$credentials=array('adminid'=>$val->admin_id,
'name'=>$val->name,
'username'=>$val->username);
}
// Set Session
$this->session->set_userdata("login_detail",$credentials);
$this->load->view('dashboard1');
} else {
echo "access denied";
}
// Get session;
$sessionArray=$this->session->userdata("login_detail");

相关内容

  • 没有找到相关文章

最新更新