Categories
Joomla

Access Cookie Information from Joomla

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:

Create a Module

$user =JFactory::getUser();
echo 'Welcome ' . $user->name;

Add Module in Article

{loadposition myposition}

Use Set Cookie

echo 'Welcome ' . JRequest::getString('username', '', 'cookie');

This way, you can easily access any cookie information from Joomla articles. If you are facing any problem, then request a quote for Joomla Module customization.