I'm setting a session variable from external file using ajax:
define( '_JEXEC', 1);
define( 'DS', DIRECTORY_SEPARATOR );
define( 'JPATH_BASE', realpath(dirname(__FILE__) .'/' ) );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$session = JFactory::getSession();
$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
// $session->clear( 'ss');
if (isset($_POST['v'])) {
$value = filter_input(INPUT_POST, 'v', FILTER_SANITIZE_NUMBER_INT);
$session->set('ss', $value);
$response = $session->get('ss');
// echo $response;
} else {
echo $session->get('ss');
}
So with that I'm setting my session var from external file, now the problem I have is retrieving it, say you need to retrieve that session value from a helper file:
public function calculation($carreton) {
// lots of line to make some calculations
$session =& JFactory::getSession();
if ($session->get('ss') == 1) {
$seg = 1000;
$subtotal_e = $subtotal + $seg;
} else {
$subtotal_e = 0;
}
// Final results
return $someArrs;
}
So the IF a = b is working fine the problem is retrieving the values from the session that I have set from external file...
Any idea how to retrieve that value?.. maybe I'm setting it wrong, the file that sets the session is in the root file... domain.com/sess.php but the helper file is in components/com_carreton/helper/file.php
Any ideas?
Thank you.