How to set (Create), Access and Delete Cookies in codeigniter ?

I can easy way to Set, Get and Delete Cookies with PHP CodeIgniter using Cookie Helper, Cookie Helper data contains functions that assist in working with very well cookies set get and unset.

How to Set, Get and Delete Cookies in CodeIgniter?

Before using Cookie Helper functions you Should load cookie Helper, in the bellow methods :


The bellow functions are available with Cookie Helper methods: set_cookie(), get_cookie() and delete_cookie()

Also Read: Session Management in CodeIgniter with PHP

IMP Note :

  • set_cookie() is alias to $this->input->set_cookie()
  • get_cookie() is alias to $this->input->cookie();

set cookie expire time in codeigniter

set cookie

$cookieInfoData = array(
		'name'   => 'home_set',
		'value'  => 'Welcome To Pakainfo Website',
		'expire' => time()+86500,
		'domain' => '.localhost',
		'path'   => '/',
		'prefix' => 'pakainfo_',


how to get array in cookie

get cookie


unset cookie in codeigniter

delete cookie

$cookieInfoData = array(
    'name'   => 'home_set',
    'value'  => '',
    'expire' => '0',
    'domain' => '.localhost',
    'prefix' => 'pakainfo_'

Also Read This πŸ‘‰   Laravel 6 Collection Filter Method Examples