+91 99674 50288

Cookies- Set Cookies in Codeigniter

Cookie is file with unique Id that stored on your local machine. When you visits some kind of shopping or e-commerce or booking websites that websites server drop one file with unique id in your internet browser history. Stores browsing details like preferences, Login details, pages clicked, what had you searched, how much time you had active on that specific website. Websites do that to enhance the user preferences and give you good recommended result when you visit the same website next time. Sites can use cookies to improve your browsing experience, for example, to keep you signed in or to remember items in your shopping cart. Cookie is just use to identify the user. The size of the cookie file will be 4 KB. 

Cookies may be of two types

Session Cookies : Session cookies is the cookies that will expire after you have logged off the websites.

Persistent Cookie : Persistent cookie remain your system even and after you have logged off from the websites.

Following Kinds of information cookies are stored in your system

1 . Name of Cookies

2. Cookie expiration

3. Unique ID

When you visit again same website the websites server matches that unique id with their own database and load that websites according to your browsing Cookies history.

There are two types

Normal cookies: These cookies are stored by the websites that you visited. that are trusted cookies which are not harmful for our system.

Third party cookies : Third party cookies are come from the advertisement sites that may very harmful for you because it work across the all websites cookies that you store in your computer. It can steal your private data from your browser history. because cookies data are not in encrypted form. You can also enable or disable cookies from your computer. Morden day browsers give options to allow, disallow or limit cookies on your system

Go to chrome setting->privacy and security->cookies and other site data->click on block all cookies.

-You can also block third party cookies from there and disallow the site’s to use cookies to see your browsing activity across the different sites

- Go to chrome setting->privacy and security->cookies and other site data->click on Block third-party cookies.

-You can also block allow cookies from there and improve your browsing experience for example keep me signed in or to remember.

- Go to chrome setting->privacy and security->cookies and other site data->click on Allow all cookies.

You can store create, read, update and delete the cookies

Cokies in codeigniter


You can set cookies using set_cookie function

SetCookies Parameters

$name = Name of the cookie

$value = Cookie data

$expire =Cookie expiry time

$domain = name of the domain on which you set the cookie

$path = cookie path

$prefix = cookie name aliases

$secure = send the cookie through HTTPS or HTTP

Syntax for


$this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);


echo get_cookie($name );