title: How do I view a session variable using Flask/Jinja2?
body: <p>Can anyone tell me how I can view a session variable within flask, so that I can retreive the current logged in user?  With my 'for loop' I can view all items iterated, but I need the current logged in user...</p>
  
  <p>Thanks in advance</p>
  
  <p>app.py</p>
  
  <pre><code>engine = create_engine('sqlite:///dude.db', echo=True)
  app = Flask(__name__)
  @app.route('/')
  def home():
      if session.get('logged_in'):
          Session = sessionmaker(bind=engine)
          s = Session()
          user = s.query(User.username)
          for i in user:
              print i
          return render_template('index.html', user = user)
      else:
          return render_template('index.html')
  </code></pre>