Code: Select all
$app = JFactory::getApplication();
$app->set('examplevariable', '123455654321');
Code: Select all
$app =& JFactory::getApplication();
echo 'currtime is ' . $app->get('examplevariable');
What's the right way of setting a variable that's accessible from anywhere in the application? If it's the above way, what am I doing wrong? These are not user-dependent, so storing them in the session doesn't seem like the right way (and in my experience the session changes require an additional page refresh), but the values will change several times during a person's session (this is an login-only application) and I need the variable to be updated the first time someone navigates to a new page after the value is changed (as stored in a database table), and I can't have the value cached, as it must be up-to-date immediately. The variables I want accessible are mostly string and integers, but there's some complex logic for working them out, so I'd rather only do it once per page load.
Thanks in advance for the help. Sounds like something that would be a common requirement.