我正在尝试更新userdata会话中的一个值。我设置了这样的用户数据:
$data_e = array (
'id' => $get[0]->id,
'name' => $get[0]->name,
'id_company' => $get[0]->id_company
);
$this->session->set_userdata('user_data', $data_e);
我试过这样做:
$data['name'] = $this->clean_input->clean($this->input->post('name', TRUE));
$this->session->set_userdata('name', $data['name']);
但它不起作用。谢谢你的帮助
答案 0 :(得分:2)
希望这会对你有所帮助:
检查会话,销毁它然后重新初始化
if ($this->session->has_userdata('name'))
{
$this->session->unset_userdata('name');
$data['name'] = $this->clean_input->clean($this->input->post('name', TRUE));
$this->session->set_userdata('name', $data['name']);
}
了解更多:https://www.codeigniter.com/user_guide/libraries/sessions.html