I'm having an issue keeping session data through ajax calls in a custom component.
In a model file of the component, there is a loop updating a session variable:
Code: Select all
$i = 0;
$count = 1000000;
foreach ($tables as $table)
{
//heavy sql queries here, so the loop takes a while to complete
//set progress
$progress = ceil((($i+1)*100)/$count);
myHelper::updateProgress($progress);
$i++;
}
In a helper file, i have 2 functions, to read and write the session variable
Code: Select all
class myHelper
{
public static function updateProgress($val)
{
$session = JFactory::getSession();
$session->set('progress', $val);
}
public static function getProgress()
{
$session = JFactory::getSession();
return $session->get('progress');
}
}
But if I try to get the current value of the var in an ajax call, I get null.
If I use $_SESSION rather than the Joomla! native functions, I can read the values through the ajax call.
Why is the session value not readable through ajax?
Am I missing something or mis using the Joomla native sessions?
Thanks a lot for your answers.