Most of us know of the dangers of using global variables in our code. The old saw was: DON'T. It was far better to pass variables around to only those functions that needed to "know" those variables.
But since we are dealing with web pages now, it appears to me that this bit of style may be outdated. For example, I have several button functions that I have designed to handle various tasks. And I try to keep the same color scheme for these buttons, e.g., red for delete, etc.
Now there are two ways I can approach this:
hard code the colors in each button function.
pass the appropriate color to the button function.
I like the second way much better for obvious reasons of flexibility. But then, where to store those color variables?
There are also two ways I can approach this:
set variables on each page that calls the button functions with the appropriate colors.
set these variables once, and only once, as session variables (the global approach).
Anybody have any thoughts on the second approach, and what it drawbacks might be?