I am trying to pass some variable from a PHP module (Sourcerer) to custom PHP script using Sessions method (as posted here). The method works fine between two PHP scripts but when I tried to implement it between a module and a script, it fails.

Overview of the my method :

Code inside php module :

echo 'Welcome to page #1';
$_SESSION['favcolor'] = 'green';

Code inside php script :

echo 'Welcome to page #2<br />';
echo $_SESSION['favcolor'];

Help would be appreciated.


You shouldn't use using $_SESSION with Joomla, but instead JFactory::getSession().

Try the following:


$session = JFactory::getSession();
$session->set('favcolor', 'green');

PHP file:

$session = JFactory::getSession();

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.