The purpose of accessing cookie information is to display custom messages like, Welcome, [username]. You can easily extract the user’s name using cookies and view it on the front end. Apart from this, you also need to access cookie information from Joomla articles for several reasons.
So having said that, the point here is how you can access cookie information from Joomla articles for displaying.
The only way to access cookie information from the Joomla article is through modules. You can’t access the cookie from the article itself. It is because PHP codes cannot be inserted in the Joomla article, the editor strips it.
But you can easily access cookie information from Joomla article in the following way:
$user =JFactory::getUser(); echo 'Welcome ' . $user->name;
echo 'Welcome ' . JRequest::getString('username', '', 'cookie');