Using Session Variables

In Server Connect you can define, use and re-use Session Variables. Once you define your session variables, they become available to choose in the dynamic data picker.

Defining a session variable is easy. In your server action, under Globals you will find $_Session:

Right click it, and add Variable:

Screenshot_67

Then add a name for this variable- this is your session variable name:

Screenshot_68

This can also be an existing session, created in some other script which you want to use in your server actions.
After you define it, the session becomes available in the dynamic data picker dialog, so you can use it wherever you need its value:


WapplerPrevious   WapplerNext


6 Likes

What are the uses of session array?

And how can I check if value available within the array?

Thanks @Teodor!

Can someone elucidate the other variables for someone like me who doesn’t come from a PHP background? A brief high-level explanation of how I might use each one would be very much appreciated. I ran a search for “Globals” in hopes of learning more about all of them and to avoid duplicating an existing topic. This Doc did a good job at helping me to better understand the $_SESSION variable although I would like to hear about an example scenario where it would come into use.

2 Likes

@Teodor, this may be a stupid question… but is it possible to pass a Session variable from App Connect to Server Connect?

These are different things.
Sessions used in app connect are browser sessions.
The server sessions used in server connect are a totally different thing.

What are you trying to achieve exactly?

I have a form where I pass some user submitted data long with other parameters.

From what I gather reading the forum, it seems the way to do this is to create hidden fields and populate those with my data. However, this creates a potential security issue since Post data can be manipulated.

I’d like to pass user submitted form data along with other non-user submitted parameters to a Server Connect action.

Where / what do you want to pass exactly?
Manipulating browser sessions is as easy as manipulating hidden field values...

Maybe if you are a little more detailed we will be able to provide some advice.

Happy to provide additional details.

I’m building a scheduling app. So there’s a user (with a backend profile stored in a user table) and a front desk person fills out the appointment and schedules it for day X at Y time. This information is submitted via a POST.

Then, I have user information (from the user table) such as copay (amount owed for each visit). So for the new scheduled event, I’d like to store the amount owed along with the event information submitted via the Post.

Let me know if you need more information.

So which data are you worried about? Is it this:

Correct. In some cases, I'd have to create 10+ hidden fields to pass the data. I am looking for a better way. Perhaps there is not better way, but I figured I'd ask.

Why would you need to create hidden fields?
Why not do everything on the serveside after this happens:

Filter everything on the server with your server action and pass the data there. Why send it to the front end first?

That’s a good option. In the past few days, I’ve started to place all my processing logic into SC instead of App Connect. Starting out new (to dev), one of those things that may obvious to people with experience that you learn.

In the example I provided:
Front desk person fills out the appointment and schedules it for day X at Y time. This information is submitted via a POST.

Let’s say I need to add the service description to the appointment record which is stored in the Services table.

To do this serverside, I still need the initial ServiceID to do the lookup. Do you suggest passing this in via a hidden field?