Forums

Delete single values of a session array

teazmo 09 Dec, 2015
Hi guys,

Chronoforms V5 works fine as a shopping cart system: I've created a component with a list of seminars. Every entry is a form and if you click the Submit-Button, you'll be taken to the Chronoforms-form on another page, where the productnumber is saved in a session-array:

(Form code view)
$form->data['numbers'][] = $_POST['seminarnummer'];

$session = JFactory::getSession();
$cf_numbers = $session->get('cf_numbers',array());
$cf_numbers = array_merge($cf_numbers,$form->data['numbers']);
$session->set('cf_numbers',$cf_numbers); 
$nummern = $session->get('cf_numbers',array());
$trimnummern = array_filter($nummern);
$uniquenummern = array_unique($trimnummern);
$implodenummern = implode('","',$uniquenummern);
$terminanzahl = count($uniquenummern);

This way one can choose several seminars and they all appear as a list in the Chronoforms form. Unfortunately I don't know how to delete a certain value of this session array in case someone chose the wrong seminar by providing a »DELETE«Button or something similar. Is it possible to delete those values without reloading the page (with Ajax for example)?

Thanks, Timo
GreyHead 09 Dec, 2015
Hi Timo,

I can only suggest that you experiment. I'm really not sure if the User session is available from an Ajax query. You'd have to test to open and/or start the session from the Ajax event and see if your data is there.

Bob
This topic is locked and no more replies can be posted.