get("ss", "");​which used to work, and still does in forms which are still using the old style.​But now it is empty - no data is returned.​What am I doing wrong?​Cheers​Tim"> Using Data Builder Action to save/retrieve session data - Forums

Forums

Using Data Builder Action to save/retrieve session data

tshirley 05 Jun, 2019
Hi,

I understand that the Data Builder action is now used to save session data.

So I placed a Data Builder Action, and in the Value section selected "Session" and gave a name "ss". Put nothing in the value field.

Then in the page where I wanted the session data back, I placed

$sessiondata = \GApp::session()->get("ss", "");

which used to work, and still does in forms which are still using the old style.

But now it is empty - no data is returned.

What am I doing wrong?

Cheers

Tim
tshirley 05 Jun, 2019
I have found the answer, so no need for a response.

In the Data builder the "value" field needs to reference the data to be saved. so, in the value field place {data:somefield} or {var:somevar}.

The the retrieval code

$sessiondata = \GApp::session()->get("ss", "");

recovers the data as required.

I wonder if there is a shortcode that will save the entire session data?
healyhatman 05 Jun, 2019
Answer
If you put nothing in the value field, what were you expecting to get back?

If you want to save all your fields to session, just use {data:} as the value.
tshirley 05 Jun, 2019
Actually I did try {data} .. but I forgot the colon.

Anyway, all good now.

Thanks.
healyhatman 05 Jun, 2019
Also you can use {session:xxx} to retrieve your session data (but obviously not in PHP)
saveg 20 Dec, 2019
Hello again, just wanted to double check if you meant by {session:xxx} to be inserted into action as a custom code or what exactly.
I have already tried it but the session still sends old value.
saveg 20 Dec, 2019
in a nutshell I dont want to retrieve the data only , but I want actually to set the prev session data into the current session. is this possible at all?
healyhatman 21 Dec, 2019
1 Likes
Yes I meant in Custom Code action, or wherever you want to use it (like the save data action), just not in PHP. {session:namegoeshere} will retrieve the session, {session.set:namegoeshere$valuegoeshere} sets it.

Or {session.set:namegoeshere$(data:fieldnamegoeshere)}

Or use the data builder 2 action.
saveg 24 Dec, 2019
thanks alot for clarification
This topic is locked and no more replies can be posted.