My apps are all running with “keep server running” and never use global variables.
One solution could be to make your global variable a dictionary that uses the user’s email or the session id as a key to get the user’s globals. I have never used this solution, I don’t use global variables.
A better approach is to use an Anvil table rather than a global dictionary to store user data. You could create a Globals
class that uses the Anvil user as a key to get a row from a table, then pass it around. The “pass it around” part could be a little annoying, but when you get used to it, it doesn’t hurt much. And it’s the right thing to do. Usually I pass it to the constructor of each class, so each object has access to all the globals without passing them to each method.
The table could be as simple as a 2 columns, one with the user and one with a Simple Object with all the info you need. Or you could even add one Simple Object column to the user table itself.