CF8 unset a var

pimh 14 Dec, 2025

Hi Max, 

I need to unset a var value that has been set in the form. However the problem is that when I do this in php code (within a load page), the variable seems to be gone (not visible in the debug). Nevertheless it still does exist somehow. So next time the page is loaded the value is still found via isset.

Attached an example that shows the issue. 

3 pages on page 2 if never visited the variable is being set with a timestamp. On another visit to page 2, it checks again and the value does exist. This will redirect to page 1 and reset the variable. So now when getting to page 2 is should not exist and the action should be as the first time value set, no redirect to the first page. Nevertheless the value does still exist and the page is redirected back. 

This is a small example of part of my form in which I try to monitor activity. If no activity for a while I should go back to the first page starting over again. This to prevent effects of leaving a screen unattended and people miss-using this. 

I am also open to other solutions. In this example the redirect does work, but also the next-page refuring back to page1 doesn't do a thing. This was also one of my other questions. 

Hope you can figure it out and help to get past this issue. 

Kind regards, Pim 

Private Attachment is only visible to Author & Moderators
pimh 18 Dec, 2025

Hi all, 

For those interested, I think I know why this happens. The vars are likely to be used in a php script scoped to that script or page. The unset only removes this scoped var also shown in the debug info. So it seems gone, but actually isn't. Setting another value to it like "" (empty string), will work. So this was also my solution. Kind regards,Pim 

Max_admin 20 Dec, 2025
Answer

Hi Pim

If you want to unset a variable then set it's value to NULL, then check later if it's null or not.

form Vars are stored in the form session, they get cleared when the form page group is finished (at the last page submit) or if you call the Clear Form Data action

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
pimh 21 Dec, 2025
1 Likes

Hi max,

thanks for the answer, it confirms my thoughts. Setting the value to null is somewhat similar to my empty string solution. However it is better in case the variable should represent a number instead of a string.

so indeed solved.

many thanks for confirming and the solution.

kind regards,

Pim

Max_admin 21 Dec, 2025

No problem! :)

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Post a Reply