# Local Data & Global Variables

**URL:** <https://forum.kirupa.com/t/local-data-global-variables/217097>\
**Category:** programming\
**Created:** [February 23, 2007, 12:18am UTC](https://forum.kirupa.com/t/local-data-global-variables/217097 "2007-02-23T00:18:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Holmesc](https://avatars.discourse-cdn.com/v4/letter/h/9f8e36/32.png) [@Holmesc](https://forum.kirupa.com/u/Holmesc)\
**Post date:** [February 23, 2007, 12:18am UTC](https://forum.kirupa.com/t/local-data-global-variables/217097/1 "2007-02-23T00:18:37Z")

</div>

Hi! I’m currently working on a game in which I have different modes, some of which I would like to be unlockable. I set up a few lines of code to cover two of the modes, ‘survival’ and ‘gate’. I \*also \*would like to be able to refer to these local variables throughout all scenes, so, after brushing up on \_global variables in the tutorial on this site, I ended up with the following:

\_global.local\_data = SharedObject.getLocal(“user\_data”);  
\_global.local\_data.data.survival = false;  
\_global.local\_data.data.gate = false;

Which all seems sound enough. I also have the code to retrieve my data:

stored\_user\_name = local\_data.data.survival;  
stored\_user\_age = local\_data.data.gate;

So, before I plunge into this, I’d like a little more information…

[LIST]  
[_]Will I be able to refer to my ‘local\_data’ variable with just \_global. in front of it?  
[_]Will the following code work: if(\_global.local\_data == true) {  
[\*]Is there a better/more efficient way to do this?[/LIST]Thanks for your help!
