0

I have a problem, I hope that you can help me: I programing a litle component and module in Joomla.

This component and module read a variable of 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 not works (and if I do a var_dump($mymessage) it shows NULL).

Moreover, this code works time after :S

Any idea? A lot of thanks!

mreig
  • 177
  • 1
  • 3
  • 11
  • I enabled Joomla's debud console, and I see that the php session var exists and it is correct (so it is logical, that it appears at Joomla's module). So, the problem is: Why the vars dissapears by Joomla component? Thanks! – mreig Aug 27 '20 at 11:14
  • Please always post your Joomla questions on [joomla.se] Stack Exchange. – mickmackusa Aug 28 '20 at 06:21
  • Where are you putting that code in the component. view file, model file. You have to mention that. – Amit Ray Aug 31 '20 at 06:24
  • Hello @AmitRay, The correct site to view this information will be in controller file. – mreig Sep 04 '20 at 16:19

0 Answers0