I'm using JSession (in Joomla 3.9.x) to implement sort of a captcha field in a form, apparently the captcha code is been saved correctly in the session but I can't find the way to retrieve it, and when I'm trying to find how to use it in the Joomla Documentation, I got to API archived pages (what does "archived" mean?, that they are from older Joomla version?, then how / where do I search for the current version documentation?).
This is the file structure I'm using:
| - views/ | - | - form/ | - | - captcha/
... then in the form (
./views/form/tmpl/default.php) I'm calling the captcha in this way:
<img src="<?php echo JURI::root(); ?>index.php?option=my_component&view=captcha&format=raw" width="120" height="40" />
... in the
display method of the captcha view (
./views/captcha/view.raw.php), after generating the random code I'm saving it this way (following this answer):
$session = JFactory::getSession(); $session->clear('myCaptchaCode'); $session->set('myCaptchaCode', $myRandomGeneratedCode);
Then (here it comes!) when I'm testing my session variables in the form (
./views/form/tmpl/default.php), just imagine I refresh the form twice, and when I
$_SESSION['myCaptchaCode'], it has the code generated in the previous page;
JFactory::getSession->set('myCaptchaCode')has the actual (expected) code, both are empty!
What am I doing wrong, what I'm missing?