i have situation of loosing value stored in $member
variable.
class user extends ci_controller { protected $message; function list() { $data['message'] = $this->message; // it's empty $this->load->view('view', $data); } function delete($id) { $this->user_model->delete($id); $this->message = "success"; redirect('user/list'); } }
the reason of using redirect clean url. empty value $this->message
in list()
after getting redirected.
i tried making static, still no luck.
you try using flash messages:
function delete($id) { $this->user_model->delete($id); $this->session->set_flashdata('message', 'success'); redirect('user/list'); }
for need load session library in constructor of controller:
$this->load->library('session');
in view use this:
<?php echo $this->session->flashdata('message');?>
you can preserve data in flash messages several requests this:
$this->session->keep_flashdata('message');
have @ this link
Comments
Post a Comment