Forums

How to read the session data?

likigoldenstar 12 Oct, 2012
Hi I loaded the session data in the form load!
How can I retrieve the session data?

e.g. session->get("my_data");

I am going to do the following:
If session data is not empty, I want to skip the form!
If empty, I will be required to fill the form.
Looking forward to your reply.
Thanks.
GreyHead 12 Oct, 2012
Hi likigoldenstar,

You can use the Session to Data action to recover ChronoForms data saved with a Data to Session action.

Otherwise you can use the Joomla! code in a Custom Code action:
<?php
$session =& JFactory::getSession();
$some_var = $session->get('xxx');
. . .
?>

Bob
dspweb 24 Oct, 2012
Hi,
what is the difference between using
<?php
$session =& JFactory::getSession();
$some_var = $session->get('xxx');
. . .
?>

and
<?php
$var = $form->data['xxx'];
?>


Thanks
DSPWEB
GreyHead 24 Oct, 2012
Hi dspweb,

The first one gets a value from the User Session, this could be data from the form but doesn't have to be.

The second one sets a variable to a value from the ChronoForms $form->data[] array; ChronoForms pre-loads this with values from the URL and from a form when it is submitted (and some other things).

Bob
dspweb 24 Oct, 2012
Thanks Bob,

So if I had a multi-page form, which method should I use to read the variables that I saved with the action 'Data to Session'?

Thanks,
DSPWEB


EDIT: Another question is: For reading saved data i should use
<?php
$var = $form->data['xxx'];
?>


OR

<?php
$var = $_POST['xxx'];
?>
GreyHead 24 Oct, 2012
Hi dspweb,

If you add a 'Session to Data' action at the beginning of the event then ChronoFroms will copy the saved data from the Session back into the $form->data[] array.

Bob
dspweb 25 Oct, 2012
Thanks Bob,

I've another question for you.
I have a multipage form with 'dynamic dropdown' action;
when I insert values and click submit, I show a confirmation page.
I have add two buttons like 'CONFIRM' and 'MODIFY';
If I click on 'MODIFY' the form come back to the previous page, and all the fields had the same value except the 'dynamic dropdown'.

How can I fix this?

PS: Excuse for my english 😶
GreyHead 25 Oct, 2012
Hi dspweb,

I'm not sure how to get this to work. It must be possible. Somehow the options list needs to be recreated when the page loads. How are you getting the options for the dynamic drop-down? It may be simplest to re-run the Ajax call on the page load.

Bob
dspweb 25 Oct, 2012
Thanks Bob,

I'm sure it is not in the correct topic, but I have another question.
This is my situation:
Multi-page form + forward button and back button in the second page.
Why if I click the back button, the previous object 'formCheck_form_name' (referred to the first page) disappears?
GreyHead 25 Oct, 2012
Hi dspweb,

I'm not sure, FormCheck is normally loaded by the Show HTML action. I can't see why it wouldn't be there :-(

Please post a link to the form so I can take a quick look.

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