title: Using global variable in Alexa Skill
body: <p>I'm wondering whether it is safe to use global variables in my Alexa Skill. Here is my setup:</p>
  
  <pre><code>* Python skill using flask-ask
  * Deployed using Zappa as aws-lambda function
  * Accessed over the AWS API gateway 
  * Is an endpoint for an Alexa Skill with multiple languages
  </code></pre>
  
  <p>Consequently, I must identify each users language at the beginning. Then I must serve him the dialogues in this language for the remainder of the interaction. My idea is to use the <code>on_session_started</code> decorator. Something like this:</p>
  
  <pre><code>@ask.on_session_started
  def new_session():
      global LANG
      if x:
          LANG = "EN"
      else:
          LANG = "DE"
  </code></pre>
  
  <p>There are several issues at play here. Because everything is so intertwined I'm really unsure about potential issues. In particular my uncertainty has to do with these aspect:</p>
  
  <ul>
  <li>Lambda functions run in containers. On consecutive calls either the same container is used or a new one is created.
  
  <ol>
  <li>How does this affect flask-ask in general?</li>
  <li>How does this affect a user session, which consists of multiple questions &lt;-> answers?</li>
  </ol></li>
  <li>Since I use the <code>on_session_started</code> decorator the global variable is only set once, at the beginning of the session:
  
  <ul>
  <li>How does this affect 2.? Could it be that between the first user request and the second request Lambda uses a new container and LANG is reset? Or is the same flask(-ask) instance active until the session ends?</li>
  </ul></li>
  </ul>