I have tried to set session variable in template index.php file and it's working fine and getting that session variable every where.
$session = JFactory::getSession();
$session->set('CountryCode', 'in');
but there is problem when i open article using direct url in browser then first time i am getting session variable blank, but i refresh same page then i get session variable perfectly.
so, can you help me in which file i set session variable so that i get in each and every component of site, and also when i load page first time.
The template rendering happens after the component execution.
You can try to create a system plugin which is executed before the component.
This link contains the available events where you can hook in. https://docs.joomla.org/Plugin/Events/System#onAfterInitialise
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.