Referencing session variables in php

Retrieve session variable values in ChronoForms v8.

Overview

The issue occurs when trying to access a session variable set in one form from a different form, resulting in an empty value.
Use the ChronoSession::get method with the variable name and a default value, or employ the {session:var_name default} placeholder in form settings to correctly reference the session data.

Answered
ChronoForms v7
nl 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 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.
nl 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 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.
ze zest96 23 Jul, 2025

Hi Max, Can you elaborate this?

I'd like to get session data from a form inside an iframe an merge it with the top.window's data.

in old CF, you had data-to-session and session-to-data which I think did the trick.

How can I achieve this with V8?

Post a Reply