Buy Now
Sign in

Session handling

rtobias , May 02 2017
R
rtobias
I'm trying to figure out how to handle using sessions for multi-form interaction. In CF5, I would use a setup along these lines:

    Towards the end of a Log In form, I would use the Data to Session action with a specified key.

    I would redirect to a page with another form, but all of my "Logged In" forms would be similar - they used the Session to Data action to check for a certain session variable that indicated if someone was logged in (usually I did this in the Load Event and used an Event Switcher to either render the form or indicate that they need to be logged in).


I know we have in CF6 Multipage and Save to Session actions. There is also Session Cart, but I don't really understand how that is supposed to work, and I didn't see any examples for multi-form setups (there is an example of multipage forms, which is more important anyway).

I know, if nothing else, I can use a php block to load session information that way, but just wanted to check if you could shed a little light on if there is an easier way to load data from session in CF6.
Randy
admin
Hi Randy,

Lets say you are in form X, and you use a "Save to session" action, data provide is {data:}, function name is "session2", after this function is executed and as long as the user's session has not been terminated, you can access the data using {session:session2}, in the same form X or in another form Y.

So if one of the fields in the data array in form X was called "text1", you can then grab its value using: {session:session2.text1}

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
R
rtobias
Awesome. As always, thanks a bunch Max!
Randy
R
rtobias
Just confirming, when you say function name, that is the name of the Save to Session action? In my case, it was defaulted to "save_to_session20". Sound about right? In my form Y, I would use {session:save_to_session20} to get all of {data:} from form X? (And if I wanted just one field, it would be {session:save_to_session20.email})
Randy
admin
Hi Randy,

Yes, correct!

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!