Assignment of Session Variable to a Set Value in a Server Action Is Incorrect

Wappler 3.0.0 b1

Step 1. Assign something to a session variable called session_test.
Step 2. Create a Set Value called variable_test
Step 3. Use the menu system to assign the value of session_test to variable_test

The menu system assigns {{session_test}} and I obviously need it to assign {{$_SESSION.session_test}}.

This clearly is a bug because {{session_test}} has no value!

(The reason I am using sessions in this way is to create a global variable I can use before, during and after a repeat…)

=========================================
Example of real world use - each item marked with a red X I had to edit the code for…
(error - except the first red X!)

So what do you pick in the menu exactly?
Are you picking the session name under the global $_SESSION variables or are you just selecting the set session step?

I’m selecting the set session step.

With so many variable names going on in a real world design, and as you design sometimes wanting to change those names slightly so you have complete consistency and understanding (in this case of a complex forex based accounting system), it is an extra and error prone step to also maintain the name of a session variable that you are only using in this server action within the $_SESSIONs list too.

I cannot see any use for selecting the Set Session step not to return the value of {{$_SESSION.session_test}}, is there?

This makes no sense at all.
If you want to use a session value you should select it from the Session variables list. The same way as you select a POST variable or a GET variable or any SERVER variable …

Selecting a step in server action steps, just selects the step and gets any data it outputs (if any).

Thanks for your thoughts Teodor… we clearly see this in different ways!

So can you tell me,

  • Why does Wappler allow me to pick a value that has no output?

  • And since I am selecting from an assignment to a session variable - which clearly is the most up to date definition of that session variable’s existance - why is it not sensible for that selection to correctly reference that session variable… rather than referencing something that has no value?

Thanks!
Antony.

If you use the value only in the current action file then I wouldn’t use a session, just use the setValue. When you set the value outside the repeater then you can access it inside your repeater and conditions. Even when you set a value inside an other scope, you can set a global name under which it is always accessible.

Hi there Patrick…

Thanks for that feedback, it is kind of helpful…

but I am still really confused about the use of normal names, global names, names starting with or without $parent, what can be set and read inside and outside of a scope (e.g. repeat) and how it differs in server actions and flows.

I used the session variable after advice from @Hyperbytes who I take as one of our community’s experts on all this stuff.

Is it possible you can write some enlightening words about it all here or @George, a team member could write a short “How To” on this subject?

Many thanks,
Antony.

Have you read this?

1 Like