Im Building a MongoDB-backed Flask project for a web application using python. I am trying to have it so that when a user is logged in the navbar displays the logout option. What i have tried so far is this if statement but all that is happening is the logout option in the navbar isnt ever appearing regardless of whether or not a user is logged in or out. Any suggestions on how to approach this? im super new to everything so im stumped.

```js
# This is the login functionality route
@app.route('/login', methods=['POST'])
def login():
    users = mongo.db.users
    account_user = users.find_one({'name': request.form['username']})
    print (account_user)
    if account_user:
        print(request.form['password'].encode('utf-8'))
        if bcrypt.hashpw(request.form['password'].encode('utf-8'), account_user['password']) == account_user['password']:
            session['username'] = account_user['name']
            session['user_id'] = str(account_user['_id'])

            return redirect('userprofile')

    return 'Invalid username/password combination'
```

```html
  <nav>
    <div class="nav-wrapper grey darken-1">
      <a href="#" class="brand-logo right">B&A</a>
      <ul id="nav-mobile" class="left hide-on-med-and-down">
      {%if session['username'] == True%}
            <li><a href="{{url_for('logout')}}">Logout</a></li>
       {%else%}
           <li><a href="{{url_for('login')}}">Login</a></li>
        {% endif %}
         <li><a href="{{url_for('index_page')}}">Home</a></li>
        <li><a href="{{url_for('register')}}">Register</a></li>
          <li><a class="dropdown-button" href="#!" data-activates="dropdown1">Search Exercises<i class="material-icons right">arrow_drop_down</i></a></li>
      </ul>
    </div>

  </nav>
```