Forums

Clearing session data when you redirect at the end of a form

CraigH 28 Feb, 2025

I have found that the session data for a multipage form is cleared if you complete the form without any redirects, so that if a user starts the form again the fields are all empty or at their defaults.  However, if you do a redirect at the end of the last page submission the session data is not cleared so that if a user restarts the form the previous form field values are displayed.

I tried using a variables action setting individual session variables to null but that did not work for me.

However, with some debugging I found a bit of PHP that does this for me. The below example enqueues a "form completed" message and clears the session data for the form prior to a redirect action. 

JFactory::getApplication()->enqueueMessage('Craft booked, do not forget to pay', 'info');
$session = Joomla\CMS\Session\Session::getInstance();
$session->clear("chronoforms8_data_1");

I want to check if there is a proper or better way of doing this in CF8?

Max_admin 01 Mar, 2025
Answer
1 Likes

Hi Craig

Thanks for posting about this, your code is ok but it will not clear all the session data, and the code will have to be changed based on the form, I have added a new setting to the Redirect action to do just that:

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.