i want to set session in my controller and access the session data inside the methods. Can anyone tell me a way to implement this? and below is my code block
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";
}
this way iam set session but it shows null on the next method.
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");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.