I have a variable which holds some value. I need to get this variable value both in administrator and site. Where should I place the variable and how can I get the variable in components or everywhere?


Administrator and your front-end site are two different sites. To share information between them, you can use some persistent mechanism like below.

1) Store information in database tables and access using Joomla Dbo.


2) Use cookies to access the information by setting cookie at root level (/)

$cookies = JFactory::getApplication()->input->cookie;
$cookies->set($name, $value, $expire, '/');

3) Store information in temporary file and access it wherever needed.


Additional Notes:

If you want to share any information within same application (either on site or admin), you can set it to Application and access it within same site in same request.

$app = JFactory::getApplication();
$app->set('some_variable', 'some_value');
$someValue = $app->get('some_variable');

If you want to access a variable across the requests but within same application, you can use JSession

$session = JFactory::getSession();
$session->set('some_variable', "some_value");
echo $session->get('some_variable');
  • 1
    Depending on what kind of value it is, it could be made an extension parameter which is stored in the database. This way the datbase saving/quering is taken care of by Joomla :) – Bakual Jun 1 '15 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.