How to store or retreive a global variable client side

I use a global variable "subdomain" (set in global.php) in my server side flows that I have set up like this:
image

This works great and I can access it in all server side actions.

I use this (among others) for users to store their uploaded files in a seperated folder:
image

But now on the client side pages, how can I access this global variable?
What is the best way to store and retreive such variables?
Is there maybe a different/better way?

Any help is highly appreciated. Thnx

Nobody?
Shouldn't be very difficult I imagine...?

Well the $_SERVER variables are available on the server side, not on the client side.
You can use set value and enable output to output the value on the page.

I don't know in PHP, but in NodeJS you can use server-side binding

If your page has an autorun server action, you can set a variable in the API, mark it "output" and retrieve it client-side.

I do what you're asking about with my Stripe tables. I have global variables that grab the correct pricing table based on which environment I'm viewing...

<%=_('$_ENV.stripe_artist_pricing_table_id',locals)%>

"stripe_artist_pricing_table_id" is a global variable and I reference it from $_ENV

Not sure how to implement all your suggestions, but thanks for your help.

Because I am not sure how to do what you mean, I did it the way I know but I am not sure if this is the most efficient way:

(my server environment is php btw)
I created a new api action with a set value to output the subdomain:

image

And on the page I load a serverconnect and output the value like this: {{scTenant.data.subdomain}}

This works, but I was hoping for an easier way to get access to global variables.

Is there a better way or is this how it must be done?

2 things:

  1. Using the {{variable}} in code mixed with the other syntax ddUser.data.user_id does not work:
    <img alt="image" dmx-bind:src="'/uploads/{{scTenant.data.subdomain}}/profile/'+ddUser.data.user_id+'/thumb/'+ddUser.data.photo">
    With this I mean, the wappler variables from the server connect are not rendered into it's variable value:
<img alt="image" dmx-bind:src="'/uploads/{{scTenant.data.subdomain}}/profile/'+ddUser.data.user_id+'/thumb/'+ddUser.data.photo" src="'/uploads/www/profile/'+ddUser.data.user_id+'/thumb/'+ddUser.data.photo">

Is this expected behaviour?

  1. I think session variables would be better in this case; no need to create a server connect on every page right?

If that's right, what is the Wappler way to use session variables in a page?
Right now I use the old php way:

<?php echo $_SESSION['mysessionvariable']; ?>

But I am sure there is a Wappler way?

That’s wrong syntax.
This is correct:

<img alt="image" dmx-bind:src="'/uploads/'+scTenant.data.subdomain+'/profile/'+ddUser.data.user_id+'/thumb/'+ddUser.data.photo">

Also don’t confuse server sessions with browser sessions. You can’t access server side sessions from the front end directly. For this you have to use php code, or output them via a server action on the page.

Someone asked the same thing and there's no meaningful reply:

For PHP that's your best way in my opinion. For NodeJS Wappler has the official feature server-side binding

I think there is a better method.

Hopefully there will an even better method soon (in version 7 according to @George):