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->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 echo:

  • the $_SESSION['myCaptchaCode'], it has the code generated in the previous page;
  • and neither the JFactory::getSession->get('myCaptchaCode') nor the JFactory::getSession->set('myCaptchaCode') has the actual (expected) code, both are empty!

What am I doing wrong, what I'm missing?

1 Answer 1


JFactory::getSession is a method (function). JFactory::getSession()->get('myCaptchaCode') should do what you expect.

  • This answer has been autoflagged by the system for its length. Can you perhaps expand on your insights by providing additional relevant insights or links to documentation? Apr 28, 2021 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.