title: Flask Signing In and signing out
body: <p><br>
  I am have created a sign in and sign out functionality to my Flask website. However, I am trying to hide the sign out button(on my navbar) when I am not signed in and show the sign-out button when I signed in.</p>
  
  <p>Here are my logout and login methods:</p>
  
  <pre><code>@app.route('/login', methods=['GET', 'POST'])
  def login():
      error = None
      if request.method == 'POST':
          if (request.form['username'] != 'admin') \
                  or request.form['password'] != 'admin':
              error = 'Invalid Credentials. Please try again.'
          else:
              session['logged_in'] = True
              flash('You were logged in.')
              return redirect(url_for('availability'))
      return render_template('login.html', error=error)
  
  
  @app.route('/logout')
  @login_required
  def logout():
      session.pop('logged_in', None)
      flash('You were logged out.')
      return redirect(url_for('welcome'))
  </code></pre>
  
  <p>Here is my navbar for my website:</p>
  
  <pre><code>&lt;nav class="navbar navbar-default navbar-fixed-top"&gt;
          &lt;div class="container"&gt;
              &lt;div class="navbar-header"&gt;
                  &lt;button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"&gt;
                      &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
                      &lt;span class="icon-bar"&gt;&lt;/span&gt;
                      &lt;span class="icon-bar"&gt;&lt;/span&gt;
                      &lt;span class="icon-bar"&gt;&lt;/span&gt;
                  &lt;/button&gt;
                  &lt;a class="navbar-brand" href="/"&gt;Student Support&lt;/a&gt;
              &lt;/div&gt;
              &lt;div id="navbar" class="navbar-collapse collapse "&gt;
                  &lt;ul class="nav navbar-nav"&gt;
                      &lt;li&gt;&lt;a href="/"&gt;Home&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="/aboutus"&gt;About Us&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="/faqs"&gt;FAQ'S&lt;/a&gt;&lt;/li&gt;
                      &lt;li class="active"&gt;&lt;a href="/availability"&gt;Availability&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="/Quiz"&gt;Quiz&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
                  &lt;ul class="nav navbar-nav navbar-right"&gt;
                      {% if 'session['logged_in'] == True %}
                      &lt;li&gt;&lt;a href="/logout"&gt;Logout &lt;span class="sr-only"&gt;(current)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                      {% else %}
                      &lt;li&gt;&lt;a href="/login"&gt;Login &lt;span class="sr-only"&gt;(current)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                      {% endif %}
                  &lt;/ul&gt;
              &lt;/div&gt;
              &lt;!--/.nav-collapse --&gt;
          &lt;/div&gt;
          &lt;!--/.container-fluid --&gt;
      &lt;/nav&gt;
  </code></pre>
  
  <p>As you can see I have tried to do an if statement so if 'session['logged_in'] == True % display the logout button but it ain't working.</p>