Passing variables between a PHP module and a PHP script

Ellie: 6 days ago

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.

Emery: 6 days ago

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();