如何在codeigniter中使用cookie保存临时数据?

I'am having problem on how and where i would put my codes in codeigniter. I was new in Php/CI and I was having a hard time with mvc form. I want to put my data's (vaccination record brand) in cookies so that i could store it temporary. I have tried to set my cookies and i got blank result but the data's were inserting in my database. I think i have problem with my controller's code.

my controller's code :

function vaccs($id) {
$data['title'] = $this->main_title.' | Vaccination';
$data['jslibraries'] = $this->inc_files->data_tables_scripts();
$data['uid']         = $id;
$data['employee']    = $this->vaccination_model->get_employee($id);
$data['vaccine']    = $this->vaccination_model->get_vaccinationrecord($id,0);
$data['vaccine1']   = $this->vaccination_model->get_vaccinationrecord($id,1); 
$this->load->view('vaccs',$data);

}

my view's code:

<?php
if (isset($_COOKIE['vaccine'])) {
setcookie('vaccine',$vaccine);
foreach ($_COOKIE[$vaccine] as $vaccine){ ?>

<div class="control-group">
<label class="control-label">
<?php echo '&nbsp'.'<a href="javascript:void(0);"  rel="tooltip"    
title="Delete" onclick="delete_vaccination('.$vaccine->vaccination_record_id.');"><i class="icon-minus-sign"></i></a>'.'';?><?php echo $vaccine->vaccination_record_brand;?>

</label>
</div>

Thank you for any help.

You should first load cookie helper.You can load it into autoload file inside config folder just add cookie in helper like this

$autoload['helper'] = array('cookie');

then you can set the cookie like this

<?php
      $name = 'xyz';
      $this->input->set_cookie('cookie_name', $name, 3600*2);
?>

then you can get this cookie value by this

<?php echo $this->input->cookie('cookie_name');?>