How do you set/change a server variable?

Not sure if this is a bug or just me being daft…but I can’t find a way to set a value for a $_SERVER variable used in either a global or local API/Server connect step.

Once I add a new variable, I set it’s name and can change the value type (text, array, Boolean etc). I can add validation rules. But there’s nothing in the UI to manually assign a value?

In the API steps, you can set value or set session value, but nothing for SERVER values?

Is something missing or am I missing something in my understanding?

That’s actually correct. SERVER variables come directly from the web server and are read only within Wappler.

Ok, I thought I saw a screenshot from Teo in response to a post which seemed to show you could set a value for a server variable. I must have been wrong.

Follow up question then @mebeingken. If I have a server connect file/API that uses session variable (local or global), but the API is run as a CRON job in the backend, does it still make use of the session variables? Or are they just browser based?

Cron jobs will create their own unique session–they are in a sense, just another user. If you think about it, there is really no automatic way for a cron job running on the server to know which session (which user) you want the job to run under.

With a cron, you’ll probably lookup stored values in a database if they are specific to a user or the job itself.

1 Like

That will be perfect then…was just thinking that session variables might not work outside of a ‘real user’ in a browser.

Thanks for your response.

1 Like

Cheers @scott, but unfortunately this doesn’t show anything for $_SERVER variables/values.

I’m still not sure how and why one uses them…

$_SERVER variables are global variables which can be accessed in all your server action steps.
You don’t change their values, they just provide information about paths, host, referrer etc.
https://www.w3schools.com/php/php_superglobals_server.asp

Thanks @Teodor. Sometimes it’s hard to find the answer when you don’t even know the underlying technology to search for…i.e. is it a HTML element, is it a JavaScript function, is it a PHP thing, a node thing etc etc.

So do server variables also exist/work in a NodeJS application?

Yes they do - and we replicated the most standard server variables there

1 Like

Just to reconfirm. Can I already use the same server variables listed here in Node.js within Wappler? Is there particular reference to the list of server variables have been replicated for Node.js?