How to get session values ​​from one module to another in joomla

Hey. I have two modules and user identifiers with a session are transferred from one module to the second module using the following code.

// To establish a session using joomla (first module)

$getCompID = JRequest::getVar('compID'); $session =& JFactory::getSession(); $session->set('comID', $getCompID); 

// To get a session with joomla (second module)

 $session = JFactory::getSession(); echo $session->get('comID'); 

I cannot get the session value in the second module. Plz help me.

+4
source share
1 answer

There is a possibility that either you did not reload the page in the first module, but tried to establish a session and access the session in the second module.

so first try reloading the same page in the first module and assigning a session or you should use the following code in the second module

$getCompID = JRequest::getVar('compID');

$session =& JFactory::getSession();

$session->set('comID', $getCompID);

echo $session->get('comID');

Pass your variable in "compID" to the second module and try to establish a session there

+2
source

All Articles