我有这个代码正在运行,但我想刷新我的会话,当我更新个人资料图片当前的图片将由新图片改变我不知道该做什么这部分$this->session->???
帮助将是欣赏
public function upload()
{
$config['upload_path'] = './assets/default_image/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_width'] = '1000';
$config['max_height'] = '1000';
$config['min_width'] = '768';
$config['min_height'] = '768';
$config['max_size'] = '204800';
$this->load->library('upload',$config);
if(!$this->upload->do_upload()){
$error = array('error' => $this->upload->display_errors());
$this->load->view('funct/upload_image',$error);
}else{
$data=array('upload_image' => $this->upload->data());
$id=$this->input->post('did');
$info=$this->upload->data();
$name = array('avatar' => $info['file_name']);
$this->resize_image($data['upload_image']['full_path'],$data['upload_image']['file_name']);
$this->user_model->get_image($id,$name);
$this->session->set_userdata('avatar',$name);
redirect('site','refreshed');
}
}
这里编辑是我朋友帮助的答案 解决方案是,在我的会话中它被排列,所以他做了他取消了排列的loggin他创建了一个新的仍然是排列形式然后就是他 解决它
public function upload()
{
$config['upload_path'] = './assets/default_image/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_width'] = '1000';
$config['max_height'] = '1000';
$config['min_width'] = '768';
$config['min_height'] = '768';
$config['max_size'] = '204800';
$this->load->library('upload',$config);
if(!$this->upload->do_upload()){
$error = array('error' => $this->upload->display_errors());
$this->load->view('funct/upload_image',$error);
}else{
$data=array('upload_image' => $this->upload->data());
$id=$this->input->post('did');
$info=$this->upload->data();
$name = array('avatar' => $info['file_name']);
$this->resize_image($data['upload_image']['full_path'],$data['upload_image']['file_name']);
$this->user_model->get_image($id,$name);
//new session
$result = $this->user_model->get_new_sess($id);
foreach($result as $row)
{
$sess_array = array('id' => $row->id,
'F_name' => $row->F_name,
'L_name'=>$row->L_name,
'username'=>$row->username,
'email'=>$row->Email,
'avatar'=>$row->avatar,
'date' =>$row->registered_date,
'position'=> $row->name);
$this->session->unset_userdata('avatar');
$this->session->set_userdata('logged_in', $sess_array);
}
$this->session->set_flashdata('item','Your profile is up-to-date');
redirect('accounts/view/'.$id);
}
这是编辑部分
答案 0 :(得分:1)
首先你摧毁你之前的头像会话
$this->session->unset_userdata('avatar');
设置新的头像会话
$this->session->set_userdata('avatar',$name);
答案 1 :(得分:0)
试试这个:
$this->session->regenerate_id();