Creating Cookies in Codeigniter
In CodeIgniter, you can use set_cookie()
$cookie = array( 'name' => 'The Cookie Name', 'value' => 'The Value', 'expire' => '86500', 'domain' => '.example.com', 'path' => '/', 'prefix' => 'myprefix_', 'secure' => TRUE);$this->input->set_cookie($cookie);
First of all you need to load cookie helper
$this->load->helper('cookie');
Set your cookie
$cookie = array( 'name' => "cookieName", 'value' => array('id'=>$rows->id, 'firstname'=>$rows->firstname, 'lastname'=>$rows->lastname, 'address'=>$rows->address, 'city'=>$rows->city, 'email'=>$rows->email, 'phone'=>$rows->phone, 'logged_in'=>TRUE ) ,'expire' => '86500',);
Just pass your array into set cookie
$this->input->set_cookie($cookie);
And you can retrieve it using
$cookie['cookieName']['id'];
Also read manual