I am programming a little component and module in Joomla.
My component and module reads a variable from the php session (this variable is set before for external php script).
External php script:
define( '_JEXEC', 1 ); define( 'JPATH_BASE', realpath(dirname(__FILE__).'/..' )); require_once ( JPATH_BASE. '/includes/defines.php' ); require_once ( JPATH_BASE. '/includes/framework.php' ); $mainframe = JFactory::getApplication('site'); $mainframe->initialise(); //session_start(); $session = JFactory::getSession(); $session->set('namevar', base64_encode('message'));` Joomla's module and component (have the same code):
$session = JFactory::getSession(); $mymessage = $session->get("namevar"); echo $mymessage ; The curious thing is that: -The module works fine. -The component does not work (and if I do a var_dump($mymessage) it shows NULL).
Moreover, this code works the time after :S
Any idea why this doesn't work the first time?
namevarsession variable?$session, I would be inclined to dump the$sessionin your both your module and then your component view, and vice versa; then you should be able to seenamevarand its value. If that checks out; how are you including the external script?