CodeIgniter Cookie Management

A cookie is a piece of information contained in a very small text file that is stored in your Internet browser or elsewhere on your hard drive. Cookies allow a website to identify a user's device whenever that user returns to the website and are commonly used in order to make websites work more efficiently.

Cookie Helper

The Codeigniter Cookie Helper file contains functions that assist in working with cookies.

  • Loading Codeigniter Cookie Helper
  • Available Codeigniter Cookie Functions

Loading Codeigniter Cookie Helper

This helper is loaded using the following code:


Available Codeigniter Cookie Functions

The following functions are available:

  • set_cookie(some argument)
  • get_cookie(some argument)
  • delete_cookie(some argument)


  • $name (mixed) – Cookie name or associative array of all of the parameters available to this function
  • $value (string) – Cookie value
  • $expire (int) – Number of seconds until expiration
  • $domain (string) – Cookie domain (usually:
  • $path (string) – Cookie path
  • $prefix (string) – Cookie name prefix
  • $secure (bool) – Whether to only send the cookie through HTTPS
  • $httponly (bool) – Whether to hide the cookie from JavaScript

Return type:void

This Codeigniter helper function gives you friendlier syntax to set browser cookies. Refer to the Input Library for a description of its use, as this function is an alias for

  • $index (string) – Cookie name
  • $xss_clean (bool) – Whether to apply XSS filtering to the returned value

Returns:  The cookie value or NULL if not found

Return type:mixed

echo get_cookie('cookie_name'); 


  • $name (string) – Cookie name
  • $domain (string) – Cookie domain (usually:
  • $path (string) – Cookie path
  • $prefix (string) – Cookie name prefix

Return type:void

Lets you delete a cookie. Unless you’ve set a custom path or other values, only the name of the cookie is needed.


Stack Overlode is optimized Tutorials and examples for learning and training. Examples might be simplified to improve reading and learning and understand. Tutorials and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using Stack Overlode, you agree to have read and accepted our terms of use, cookie and privacy policy.