Saved Variables are first defined in the TOC file. This tells WoW which globals to save for your addon when the user logs out.
TOC:
Code:
## SavedVariables: Global_Name
## SavedVariablesPerCharacter: Global_Name
It's pretty straightforward what each line does. The first is used to register the global
Global_Name to be saved account-wide. The second does this just for the character you logged on. That's only half of it as you need to define the global in Lua too just like any other variable. The only difference is WoW saves the variable and fires PLAYER_LOGOUT when logging out or reloading UI. Saved data if any is available when ADDON_LOADED fires for your addon.