Globals get saved to a globals.xml file that gets placed in your save game directory when you save the game. You can set and get global variables with the SetGlobal* and GetGlobal* functions.
These variables exist at a level similar to the campaign folder, meaning they exist in the context of a saved game and can cross from one module to another. They are not physically written to the xml file until a save happens, however.
A good way to check that your variables are getting saved correctly is to save the game an open the file.
One important thing to note is that global variable names can have spaces, but they cannot be more than 32 characters long.