Referencing session variables in php

nlheath 27 May, 2025

I am not able to retrieve the value of a session variable in a php custom code module.  I have set up a session variable named xx_srch_surname in a form.  When I redirect to another form, I execute a php custom code, which shows the value of the session data using print_r($_SESSION), and my variable name and its value appear.  But if I try to echo the variable using $_SESSION['xx_srch_surname'] or $session->data['xx_srch_surname'], the variable is empty.  What is the correct format to reference this variable from php custom code?

Hope someone can help.

Max_admin 27 May, 2025

you set the variable in one form and try to get it in a different form or a different form page ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
nlheath 28 May, 2025

Yes, that is correct.  I set it in one form and need to get it in a different form, but it comes up empty in the second form.

Max_admin 28 May, 2025
Answer

You can print the whole $_SESSION global variable to find the path to the variable you need

in v8 you can use:

ChronoSession::get("var_name", default);

or

{session:var_name default} in form settings
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.