Declare public variables to hold application settings

Jun 22, 2015 at 10:29 PM
Hi,

I am using some variables to store application wide settings in my main.prg of my desktop application.

How can i do this in ActiveVfp?

Will these code run every time when i call avfp script from the server?

Is there a way to keep these settings persistant on server during avfp session / multiple script calls?

Regards
Naeem
Coordinator
Jun 24, 2015 at 12:05 PM
Yes, just use the session object to store everything. This remains persistent throughout the web session. Anything else that needs to be permanent store to the database.
Coordinator
Jun 24, 2015 at 1:18 PM
One thing to take in consideration is that in Web apps, you don't have a server-side code that is running permanently. Your server-side code will be executed every time you send a new request to the server, and any public variable declared in your MAIN.PRG will be alive only while the request is being processed by AVFP.

App wide settings are normally stored in some kind of configuration files and are kind of static, so reading them every time you process a request shouldn't be a problem: if a setting is updated, this change should be saved to the configuration file so the next request will read it from there.

Now, keeping information browser-side between post-backs to the server is another problem, one that can be solved (among other approaches) using sessions. For example, if you use SPA, then you can use JS global variables to store session-wide values.

Victor