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

Today, We want to share with you set cookie in codeigniter.In this post we will show you Cookies In Codeigniter, hear for how to check cookie is set or not in codeigniter? we will give you demo and example for implement.In this post, we will learn about How to set (Create), Access and Delete Cookies? with an example.

how to set cookie in codeigniter?

here you can set, get and delete cookie in codeigniter Examples.
set cookie

set_cookie($name[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = FALSE[, $httponly = FALSE]]]]]]])

get cookie

get_cookie($index[, $xss_clean = NULL]])

delete cookie

delete_cookie($name[, $domain = ''[, $path = '/'[, $prefix = '']]]])

step 1: application/config/autoload.php

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

step 2: application/controller/Product_cart_controller.php

   class Product_cart_controller extends CI_Controller {
      function __construct() {
         $this->load->helper(array('cookie', 'url'));
      public function index() {
      public function display_cookie() {
         echo get_cookie('shop_details');
      public function deletecookie() {

Free Live Chat for Any Issue

step 3: application/views/view_cookie.php

<!DOCTYPE html>
<html lang = "en">
      <meta charset = "utf-8">
      <title>CodeIgniter View Example -</title>
      <a href = 'display'>Click Here</a> to view the cookie.<br>
      <a href = 'delete'>Click Here</a> to delete the cookie.

step 4: application/config/routes.php

$route['cookie'] = "Product_cart_controller"; 
$route['cookie/display'] = "Product_cart_controller/display_cookie"; 
$route['cookie/delete'] = "Product_cart_controller/deletecookie";



I hope you get an idea about CodeIgniter Cookie Helper.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.