Sometimes it is necessary to maintain a state variable across the site.
Retrieving a variable saved
For example, to check whether Jquery is already loaded in another custom built component or module.
Setting up a state variable
$app = JFactory::getApplication(); $app->setUserState( 'myvar', $myvarvalue ); $app->setUserState( 'com_yourcomponent.data', $yourvalue );
Retrieving a variable saved
$app = JFactory::getApplication(); $variable = $app->getUserStateFromRequest( "com_yourcomponent.data" );
No comments:
Post a Comment