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?
Contents
Before using Cookie Helper functions you Should load cookie Helper, in the bellow methods :
$this->load->helper('cookie');
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_', ); set_cookie($cookieInfoData);
how to get array in cookie
get cookie
get_cookie('pakainfo_home_set');
unset cookie in codeigniter
delete cookie
$cookieInfoData = array( 'name' => 'home_set', 'value' => '', 'expire' => '0', 'domain' => '.localhost', 'prefix' => 'pakainfo_' ); delete_cookie($cookieInfoData);
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.