Please help clear up difference between using global, session variables

Hi. I understand and have obviously used variables in other apps stored in the session cookie. I have also passed values with PUT and GET in the URL. Here is my slight confusion in SC:

Say I am in the control_login app, in the validation event. I want to save some values for later use in other apps.
$glo_test = “hello”;
sc_set_global($glo_test);

The above does not allow me to reference the [glo_test] in other apps. What does the sc_set_global do?

So instead I do the following:
$glo_test = “hello”;
[glo_test] = $glo_test;
//sc_set_global($glo_test);

Now I can go to the Application - Global Variables - and I now see the glo_test used in the event. I just set it to SESSION and make it OUT. Then it is available as [glo_test] in other apps.

Other variables:
$test // is just a regular variable in my php in one particular event, correct?

{test} // is a variable that spans across multiple events ONLY in the same application, correct?

I am just really confused what that sc_set_global macro is for…

Thanks,
Jamie

Re: Please help clear up difference between using global, session variables

IIRC, as it has been a long time …

sc_set_global creates a SESSION var that is under $_SESSION[‘scriptcase’][‘var’], as does [global_var]
I think {var} creates a SESSION var that is $_SESSION[‘scriptcase’][‘app’][‘var’]
$var follows PHP rules.

It can get more detailed than this, but you get the general idea.

At the end of the day, SC uses SESSION more that you think … so it is best to create your own and have full control of where you are.

If you load your app and then go back to the SC IDE and load VIEW/Data In Session in the menu, you will see how things are allocated.

Regards,
Scott.

Re: Please help clear up difference between using global, session variables

Thanks Scott, you made my day. I didn’t know they had that view tool for session data. Very cool.
They need to pay you to rewrite help manual - or a quick start for programmers :slight_smile:
Jamie

Re: Please help clear up difference between using global, session variables

rewrite help manual

My first move would be to use a real help app like Help+Manual (http://www.ec-software.com/). There is none better for creating help files.
They really need to quit using their own solution, as it is simply terrible.

Regards,
Scott.