Set and get cookies in Joomla CMS

Now, it’s time to learn how to use cookies in Joomla!
If you want save some information in cookie or get some value from cookies then you can use $jcookie = JFactory::getApplication()->input->cookie;
Example ↓

$app = JFactory::getApplication();
$jinput = $app->input;
$jcookie  = $jinput->cookie;

$cookie_value = $jcookie->get( 'cookie_name', null); // Get cookie data  ($name, $defaultValue)

$jcookie->set( 'cookie_name', 'cookie_value', 0); // Set cookie data ($name, $value, $expire) $expire == 0: cookie lifetime is of browser session.

Continue reading Set and get cookies in Joomla CMS